#UnknownID33. XHXMMMlOPUl3Wg#['>%
XHXMMMlOPUl3Wg#['>%
Statement
Amidst skyscrapers in the bustling metropolis of Metro Manila, the newest Noiph mall in the Philippines has just been completed! The construction manager, Penchick, ordered a state-of-the-art monument to be built with pillars.
The heights of the monument's pillars can be represented as an array of positive integers, where represents the height of the -th pillar for all between and .
Penchick wants the heights of the pillars to be in non-decreasing order, i.e. for all between and . However, due to confusion, the monument was built such that the heights of the pillars are in non-increasing order instead, i.e. for all between and .
Luckily, Penchick can modify the monument and do the following operation on the pillars as many times as necessary:
- Modify the height of a pillar to any positive integer. Formally, choose an index and a positive integer . Then, assign .
Help Penchick determine the minimum number of operations needed to make the heights of the monument's pillars non-decreasing.
Format
Input
Each test contains multiple test cases. The first line contains the number of test cases ( ). The description of the test cases follows.
The first line of each test case contains a single integer ( ) — the number of pillars.
The second line of each test case contains integers ( and ) — the height of the pillars.
Please take note that the given array is non-increasing.
Note that there are no constraints on the sum of over all test cases.
Output
For each test case, output a single integer representing the minimum number of operations needed to make the heights of the pillars non-decreasing.
Sample
3
5
5 4 3 2 1
3
2 2 1
1
1
4
1
0
相关
在下列比赛中: