#a. 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
ShanghaiTech ACM 炸鱼杯
- 状态
- 已结束
- 规则
- OI
- 题目
- 46
- 开始于
- 2024-12-10 23:00
- 结束于
- 2024-12-15 13:00
- 持续时间
- 110 小时
- 主持人
- 参赛人数
- 112