# Ninja And The Strictly Increasing Array

Contributed by
Omkar Deshmukh
Medium
0/80
Avg time to solve 23 mins
Success Rate 78 %
Share

## Problem Statement

#### Your task is to help Ninja and print the minimum number of the above moves to make the array ‘B’ strictly increase.

##### Example :
``````Input: ‘N’ = 5, ‘A’ = [1, 2, 3, 4, 5]
Output: 4

Initially, array ‘B = [0, 0, 0, 0, 0], we will perform the following sequence of moves:
‘B[0] = B[0] - A[0]’
‘B[2] = B[2] + A[2]’
‘B[3] = B[3] + A[3]’
‘B[4] = B[4] + A[4]’
After these moves, the updated array will be [-1, 0, 3, 4, 5], and this is the minimum possible number of moves to make this array strictly increase.
``````
Detailed explanation ( Input/output format, Notes, Images )
##### Constraints:
``````1 ≤ T ≤ 10
2 ≤ N ≤ 10^3
1 ≤ A[i] ≤ 10^9
It is guaranteed that the sum of 'N' is ≤ 10^3 over all test cases.

Time limit: 1 sec
``````
##### Sample Input 1:
``````2
2
2 2
7
1 2 1 2 1 2 1
``````
##### Sample Output 1:
``````1
10
``````
##### Explanation For Sample Input 1:
``````For test case 1:
Initially, the array ‘B’ = [0, 0] by one move, we can make it [0, 2], and hence the answer is 1.

For test case 2:
Initially, the array ‘B’ = [0, 0, 0, 0, 0, 0, 0] by 10 moves we can make it [−3, −2, −1, 0, 1, 2,  3], and hence the answer is 10. Here 10 is the minimum possible number of moves needed to make this array strictly increasing.
``````
##### Sample Input 2:
``````2
4
2 4 1 1
6
2 1 4 1 3 5
``````
##### Sample Output 2 :
``````4
5
``````
Auto
Console