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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <iostream>

using namespace std;

class Program
{
    // fields
    int n;  // games
    long long *prices;
    long long answer;


    // exec function


public:
    // constructor
    Program()
    {
        // load data
        cin >> n;
        prices = new long long[n];
        for (int i = 0; i < n; i++)
        {
            cin >> prices[i];
        }
        answer = 0;
    }

    // public functions
    void FindAnswer()
    {
        long long delta;
        long long multiplier;
        for (int i = 1; i < n; i++)
        {
            multiplier = 1;
            while (prices[i] <= prices[i - 1])
            {
                prices[i] *= 10;
                multiplier *= 10;
                answer++;

                delta = prices[i - 1] - prices[i];
                if ((delta < multiplier - 1) && (delta >= 0))
                {
                    prices[i] = prices[i - 1] + 1;
                }
            }
        }
    }
    long long GetAnswer()
    {
        return answer;
    }
};

int main()
{
    Program P;
    P.FindAnswer();
    cout << P.GetAnswer() << endl;

    //getchar(); getchar();//---
    return 0;
}