#P9080. [PA 2018] Nowy kontrakt
[PA 2018] Nowy kontrakt
Problem Description
This problem is translated from PA 2018 Round 2 Nowy kontrakt.
You are given a sequence of positive integers. You need to make the sequence strictly increasing by appending digits to the end of numbers in the sequence. Your goal is to minimize the number of appended digits.
Appending a digit to a number means:
, where .
Input Format
The first line contains an integer , the length of the sequence.
Lines to each contain one number. Line contains the -th number in the sequence.
Output Format
Print one integer: the minimum number of operations.
3
8
5
13
2
Hint
Sample 1 Explanation
Append one digit to the 2nd number and one digit to the 3rd number, i.e., , . The new sequence becomes , which is strictly increasing. The number of operations is . There are other ways with operations, but there is no way with only operation.
Constraints
This problem uses bundled tests.
For of the testdata:
- .
- .
Translated by ChatGPT 5