9442022-02-03 19:41:02nmarciSzámjegy keveréscpp11Time limit exceeded 22/40300ms1896 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 = 0;
        while(s[i] == '0'){
            ++i;
        }
        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/02ms1748 KiB
2Accepted0/02ms1788 KiB
3Accepted0/023ms1852 KiB
4Accepted2/21ms1856 KiB
5Accepted2/21ms1860 KiB
6Accepted2/21ms1864 KiB
7Accepted2/21ms1868 KiB
8Accepted2/21ms1872 KiB
9Accepted2/21ms1876 KiB
10Accepted2/21ms1880 KiB
11Accepted4/41ms1884 KiB
12Accepted4/41ms1896 KiB
13Time limit exceeded0/2252ms992 KiB
14Time limit exceeded0/2300ms1072 KiB
15Time limit exceeded0/2256ms1080 KiB
16Time limit exceeded0/2256ms1028 KiB
17Time limit exceeded0/2256ms1108 KiB
18Time limit exceeded0/2293ms1108 KiB
19Time limit exceeded0/3270ms1056 KiB
20Time limit exceeded0/3252ms1052 KiB