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

Code

// ~/.vim/cpp_template.cpp
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define REP(i,a,b) for (int i = a; i < b; i++)

// Type Aliases for 1D and 2D vectors with initialization
#define vi(n, val) vector<int>(n, val) // 1D vector of ints with size n, initialized to val
#define vll(n, val) vector<long long>(n, val) // 1D vector of long longs with size n, initialized to val
#define ll long long
#define vvi(n, m, val) vector<vector<int>>(n, vector<int>(m, val)) // 2D vector of ints (n x m), initialized to val
#define vvll(n, m, val) vector<vector<long long>>(n, vector<long long>(m, val)) // 2D vector of long longs (n x m), initialized to val


using namespace std;

template <typename T>
void pV(const std::vector<T>& vec, const std::string& label = "Vector") {
    std::cout << label << ": [ ";
    for (const auto& elem : vec) {
        std::cout << elem << " ";
    }
    std::cout << "]" << std::endl;
}


using namespace std;


void dfs(int s, vector<bool> *visited, vector<int> (*adj)[]) {
    if ((*visited)[s]) return;
    (*visited)[s] = true;
    // process node s


    for (auto u: (*adj)[s]) {
        dfs(u, visited, adj);
    }
}
/*
vector<int> adj[N];                                                          
vector<bool> visited(N, false);
int u, v;
for(int i = 0; i < M;i++){
    cin >> u >> v;
    u--;
    v--;
    adj[u].push_back(v);
    adj[v].push_back(u);
}
*/
int maxNo(int x){
    int mx = 0;
    while(x > 0){
        mx = max(mx, x % 10);
        x/= 10;
    }
    return mx;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    // Your code starts here
    int n;
    cin >> n;

    int res = 0;
    while(n > 0){
        n-= maxNo(n);
        res++;
    }

    cout << res << endl;
    
    return 0;
}


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: ACCEPTED

input
167

correct output
29

user output
29

Test 5

Verdict: ACCEPTED

input
4434

correct output
687

user output
687

Test 6

Verdict: ACCEPTED

input
9722

correct output
1381

user output
1381

Test 7

Verdict: ACCEPTED

input
37882

correct output
5406

user output
5406

Test 8

Verdict: ACCEPTED

input
103330

correct output
13867

user output
13867

Test 9

Verdict: ACCEPTED

input
562167

correct output
75527

user output
75527

Test 10

Verdict: ACCEPTED

input
991919

correct output
127308

user output
127308

Test 11

Verdict: ACCEPTED

input
999993

correct output
128206

user output
128206

Test 12

Verdict: ACCEPTED

input
999999

correct output
128206

user output
128206

Test 13

Verdict: ACCEPTED

input
23456

correct output
3364

user output
3364