Precreation contest files
This commit is contained in:
38
misc/chuyen-de-xau/b5.cpp
Normal file
38
misc/chuyen-de-xau/b5.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
#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;
|
||||
}
|
||||
Reference in New Issue
Block a user