9452022-02-03 19:44:26nmarciSzámjegy keveréscpp11Time limit exceeded 22/40298ms1888 KiB
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <algorithm>
#include <list>
using namespace std;
using ll = long long int;

int main(){
    string s;
    cin >> s;
    int answ = 0;
    while(s.size() > 1){
        //cerr << s << endl;
        sort(s.begin(), s.end());
        int i = lower_bound(s.begin(), s.end(), '1') - s.begin();
        swap(s[0],s[i]);
        i = s.size() - 1;
        if(s[i] == '0'){
            while(s[i] == '0'){
                s[i] = '9';
                --i;
            }
        }
        --s[i];
        while(*s.begin() == '0'){
            s.erase(s.begin());
        }
        ++answ;
    }
    answ += atoi(s.c_str());
    cout << answ << endl;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base22/40
1Accepted0/02ms1740 KiB
2Accepted0/01ms1848 KiB
3Accepted0/020ms1844 KiB
4Accepted2/21ms1848 KiB
5Accepted2/21ms1852 KiB
6Accepted2/21ms1864 KiB
7Accepted2/21ms1868 KiB
8Accepted2/21ms1872 KiB
9Accepted2/21ms1876 KiB
10Accepted2/21ms1888 KiB
11Accepted4/41ms1884 KiB
12Accepted4/41ms1888 KiB
13Time limit exceeded0/2254ms1064 KiB
14Time limit exceeded0/2273ms1068 KiB
15Time limit exceeded0/2254ms1208 KiB
16Time limit exceeded0/2284ms1036 KiB
17Time limit exceeded0/2298ms1096 KiB
18Time limit exceeded0/2296ms1112 KiB
19Time limit exceeded0/3287ms1056 KiB
20Time limit exceeded0/3291ms1136 KiB