I can sort in
~ Victor, 2019
Victor has invented a brand new sorting algorithm that promises an
You have subsequently found that Victor's algorithm can be extended to any arbitrary sequence of numbers
Write a program that finds the minimum number of seconds required to convert any given
Constraints
For all subtasks:
Subtask 1 [20%]
The length of the sequence
Subtask 2 [80%]
The length of the sequence
Input Specification
The first line will contain
The next line will contain
Output Specification
Output the minimum number of seconds required to convert the given sequence into a nice sequence.
Sample Input 1
10
-6 8 6 -1 3 -8 -6 -2 5 -2
Sample Output 1
39
Explanation of Sample Output 1
We can make this a nice sequence by incrementing
Sample Input 2
5
1 2 3 4 5
Sample Output 2
0
Explanation of Sample Output 2
This is already a nice sequence.
Sample Input 3
7
7 6 5 -1 -3 -4 -5
Sample Output 3
0
Comments