Building an Increasing Sequence
Time limit2sMemory limit512 MB
Find a strictly increasing integer sequence B minimizing the total absolute difference from a given sequence A.
Problem
An integer sequence is given.
Among all integer sequences that satisfy , take one that makes as small as possible and print that minimum value.
The sequences and consist of integers only, and every element of has to lie inside the range of a 32-bit integer type.
Input
The first line contains . ()
The second line contains the elements of in order, . ()
Output
Print the smallest possible value of on one line.
Hint
For , the sequence minimizes the sum, and that minimum is 13.