#P78. P36 Hard Version: Sequence 3+
P36 Hard Version: Sequence 3+
Source
The easy version of this problem is adapted from Long Long OJ. All rights reserved.
Attention
P36 is the easy version of this problem.
Description
Given a sequence of integers, you need to add digits at the end of the integers in order to make the sequence strictly increasing.
Adding digit () at the end of a number can be represented as .
Find the minimum number of digits to be added.
Input
The first line consists of an integer .
The following lines consists of integers .
Output
Output the minimum number of digits to be added.
Samples
4
20
1
45
132
4
Tips
After adding digits, the sequence becomes .
Note that this is not the only possible solution.
For of the test cases:
- .
- .