1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <iostream>

int main() {

    unsigned int n = 1;
    unsigned long long zmiany = 0;
    unsigned long long b,z;

    std::cin >> n;

    unsigned long long tablica[200009] = {0};

    for(int i = 0; i < n; i++) {
        unsigned long long temp;
        std::cin >> temp;
        tablica[i] = temp;
        if(i == 0)continue;
        if (tablica[i - 1] >= tablica[i]) {
                b = 10;
                z = 1;
                for (int a = 0;;a++) {
                    if ((tablica[i] * b + a) > tablica[i-1]){
                        tablica[i] = tablica[i] * b + a;
                        zmiany+=z;
                        break;
                    }
                    if(a == 10){
                        a = 0;
                        b *= 10;
                        z++;
                    }
                }
        }
    }

    std::cout << zmiany;

    return 0;
}