#P15866. 【MX-X26-T2】「Cfz Round 7」Tap Tap Dance
【MX-X26-T2】「Cfz Round 7」Tap Tap Dance
Background
The direction indicated by the compass, / the direction the compass points to.
What the heart desires, / is where the heart is heading.
Problem Description
Yuki has a sequence of length .
Yuki defines one "Yuyu" operation as:
- Choose two integers such that .
- Let the of be . Delete the numbers in that are greater than , and set to be the length of the sequence after this.
You need to find the minimum number of "Yuyu" operations needed to make the sequence as short as possible.
In this problem, the of a sequence is the smallest non-negative integer that does not appear in the sequence. For example:
- .
- .
- .
In particular, when the sequence is empty, its is .
Input Format
This problem has multiple test cases.
The first line of the input contains two integers , which represent the subtask number of this test point and the number of test cases. The sample satisfies .
Then the test cases follow one by one. For each test case:
- The first line contains an integer .
- The second line contains integers .
Output Format
For each test case, output one line containing one integer, which is the minimum number of "Yuyu" operations needed to make the sequence as short as possible.
0 5
4
2 0 2 6
5
1 0 3 3 1
5
1 1 8 3 1
6
1 0 3 1 0 2
7
4 0 9 8 1 3 8
1
2
1
3
2
Hint
Sample 1 Explanation
For the st test case, you can directly choose and to perform a "Yuyu" operation, which makes the sequence become . It is easy to prove that cannot be deleted, so the length of is minimized at this point.
For the nd test case, you can first choose and to perform a "Yuyu" operation, and the sequence becomes . Then choose and to perform a "Yuyu" operation, and the sequence becomes , reaching the minimum length.
Constraints
Let denote the sum of within a single test point.
For all test cases:
- .
- , .
- For all , .
This problem uses bundled tests.
- Subtask 1 (18 points): , .
- Subtask 2 (5 points): It is guaranteed that there is no in the sequence .
- Subtask 3 (21 points): It is guaranteed that there is exactly one in the sequence .
- Subtask 4 (24 points): For all positive odd numbers not greater than , it is guaranteed that .
- Subtask 5 (32 points): No special constraints.
Translated by ChatGPT 5