CSES - Aalto Competitive Programming 2024 - wk5 - Mon - Results
Submission details
Task:Deleting digits
Sender:aalto2024e_006
Submission time:2024-09-30 16:33:50 +0300
Language:C++ (C++11)
Status:READY
Result:
Test results
testverdicttime
#1ACCEPTED0.00 sdetails
#2ACCEPTED0.00 sdetails
#3ACCEPTED0.00 sdetails
#4--details
#5--details
#6--details
#7--details
#8--details
#9--details
#10--details
#11--details
#12--details
#13--details

Code

#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>

using namespace std;


int best(int x) {

    if (x == 0) return 0;
    else if (x < 0) return 99999999;
    //cout << x << endl;

    int y = x;

    

    int miny = 99999999;
    while (y != 0) {
       //cout << y << endl;
         if (y%10 != 0) miny = min(miny, best(x - (y%10)) + 1);
        y /= 10;
    }

    return miny;
}


int main() {

    int x;
    cin >> x;

    cout << best(x) << endl;


}

Test details

Test 1

Verdict: ACCEPTED

input
4

correct output
1

user output
1

Test 2

Verdict: ACCEPTED

input
17

correct output
3

user output
3

Test 3

Verdict: ACCEPTED

input
35

correct output
7

user output
7

Test 4

Verdict:

input
167

correct output
29

user output
(empty)

Test 5

Verdict:

input
4434

correct output
687

user output
(empty)

Test 6

Verdict:

input
9722

correct output
1381

user output
(empty)

Test 7

Verdict:

input
37882

correct output
5406

user output
(empty)

Test 8

Verdict:

input
103330

correct output
13867

user output
(empty)

Test 9

Verdict:

input
562167

correct output
75527

user output
(empty)

Test 10

Verdict:

input
991919

correct output
127308

user output
(empty)

Test 11

Verdict:

input
999993

correct output
128206

user output
(empty)

Test 12

Verdict:

input
999999

correct output
128206

user output
(empty)

Test 13

Verdict:

input
23456

correct output
3364

user output
(empty)