← Home
write a go solution for B. Balancingtime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputEcrade has an integer array a_1,a_2,ldots,a_n. It's guaranteed that for each 1<=i<n, a_ineqa_i+1.Ecrade can perform several operations on the array to make it strictly increasing.In each operation, he can choose two integers l and r (1<=l<=r<=n) and replace a_l,a_l+1,ldots,a_r with any r-l+1 integers a'_l,a'_l+1,ldots,a'_r satisfying the following constraint:  For each l<=i<r, the comparison between a'_i and a'_i+1 is the same as that between a_i and a_i+1, i.e., if a_i<a_i+1, then a'_i<a'_i+1; otherwise, if a_i>a_i+1, then a'_i>a'_i+1; otherwise, if a_i=a_i+1, then a'_i=a'_i+1. Ecrade wants to know the minimum number of operations to make the array strictly increasing. However, it seems a little difficult, so please help him!InputEach test contains multiple test cases. The first line contains the number of test cases t (1<=t<=10^4). The description of the test cases follows. The first line of each test case contains a single integer n (2<=n<=2*10^5).The second line of each test case contains n integers a_1,a_2,ldots,a_n (-10^9<=a_i<=10^9).It is guaranteed that for each 1<=i<n, a_ineqa_i+1.It is guaranteed that the sum of n across all test cases does not exceed 2*10^5.OutputFor each test case, output a single integer representing the minimum number of operations to make the array strictly increasing.ExampleInput433 2 133 1 24-2 -5 5 271 9 1 9 8 1 0Output2
1
1
3
NoteIn the first test case, a possible way to obtain the minimum number of operations:  In the first operation, choose l=2,r=2 and a'_2=4, then a=[3,4,1];  In the second operation, choose l=1,r=2 and a'_1=-1,a'_2=0, then a=[-1,0,1]. In the second test case, a possible way to obtain the minimum number of operations:  In the first operation, choose l=2,r=3 and a'_2=4,a'_3=5, then a=[3,4,5]. In the third test case, a possible way to obtain the minimum number of operations:  In the first operation, choose l=2,r=3 and a'_2=-1,a'_3=1, then a=[-2,-1,1,2].. Output only the code with no comments, explanation, or additional text.