#P1861D. Sorting By Multiplication
Sorting By Multiplication
No submission language available for this problem.
Description
You are given an array of length , consisting of positive integers.
You can perform the following operation on this array any number of times (possibly zero):
- choose three integers , and such that , and multiply every such that by .
Note that you can choose any integer as , it doesn't have to be positive.
You have to calculate the minimum number of operations to make the array sorted in strictly ascending order (i. e. the condition must be satisfied).
The first line contains a single integer () — the number of test cases.
The first line of each test case contains one integer () — the length of the array .
The second line of each test case contains integers () — the array .
Additional constraint on the input: the sum of over all test cases does not exceed .
For each test case, print one integer — the minimum number of operations required to make sorted in strictly ascending order.
Input
The first line contains a single integer () — the number of test cases.
The first line of each test case contains one integer () — the length of the array .
The second line of each test case contains integers () — the array .
Additional constraint on the input: the sum of over all test cases does not exceed .
Output
For each test case, print one integer — the minimum number of operations required to make sorted in strictly ascending order.
Note
In the first test case, we can perform the operations as follows:
- , , ;
- , , ;
- , , .
In the second test case, we can perform one operation as follows:
- , , ;
- , , .
In the third test case, the array is already sorted.