We have a list of integers
Our only option is to change them by appending digits
Given the current list, what is the minimum number of single digit append operations that are necessary for the list to be in strictly increasing order?
For example, if the list is

Input Specification
The first line of the input gives the number of test cases,
Output Specification
For each test case, output one line containing Case #x: y
, where
Limits
Time limit: 10 seconds.
Memory limit: 1 GB.
Test Set 1
Test Set 2
Sample Input
4
3
100 7 10
2
10 10
3
4 19 1
3
1 2 3
Sample Output
Case #1: 4
Case #2: 1
Case #3: 2
Case #4: 0
In Sample Case #1, the input is the same as in the example given in the problem statement. As the image shows, the list can be turned into a sorted list with 4 operations. Notice that the last two integers need to end up with at least 3 digits (requiring at least 3 append operations in total). If all of the final numbers had exactly three digits, the second would be larger than the third because it starts with a 7 instead of a 1. This means we cannot do it with fewer than 4 operations.
In Sample Case #2, notice that the list needs to be in strictly increasing order, so we have to do at least one operation. In this case, any valid append operation to the second integer works.
In Sample Case #3, we can use two append operations to get the list to
In Sample Case #4, the given list is already in strictly increasing order, so no operations are necessary.
Comments