39 lines
606 B
C++
39 lines
606 B
C++
#include <bits/stdc++.h>
|
|
using namespace std;
|
|
|
|
int main() {
|
|
ios::sync_with_stdio(false);
|
|
cin.tie(nullptr);
|
|
|
|
string s;
|
|
cin >> s;
|
|
|
|
vector<char> digits;
|
|
for (char c : s) {
|
|
if (isdigit(c))
|
|
digits.push_back(c);
|
|
}
|
|
|
|
int m = digits.size();
|
|
string result = "";
|
|
int pos = 0;
|
|
|
|
for (int need = 5; need > 0; need--) {
|
|
char best = '0';
|
|
int bestPos = pos;
|
|
|
|
for (int i = pos; i <= m - need; i++) {
|
|
if (digits[i] > best) {
|
|
best = digits[i];
|
|
bestPos = i;
|
|
}
|
|
}
|
|
|
|
result.push_back(best);
|
|
pos = bestPos + 1;
|
|
}
|
|
|
|
cout << result;
|
|
return 0;
|
|
}
|