#P10922. Happybob's Numbers (UBC001B)
Happybob's Numbers (UBC001B)
Problem Description
Happybob has numbers on the ground. The -th number is denoted as . Happybob is studying how to delete all of these numbers. Before he starts all operations, he has one chance to rearrange these numbers in any order. Then he will delete numbers in the following way:
-
Happybob has a deletion index (initially ). He will set a new variable with value , and then for every positive integer satisfying , he performs (here is the current number of remaining numbers on the ground), and deletes the number . After that, he sets to .
-
If after any operation, is strictly greater than the current number of remaining numbers on the ground, then he will not be able to delete any more numbers.
Of course, with this deletion method, it may be impossible to delete all numbers. So he now asks you: what is the maximum number of numbers he can delete?
Input Format
The first line contains a positive integer , the number of test cases.
For each test case:
The first line contains a positive integer , the size of .
The second line contains positive integers, representing the elements in .
Output Format
Output lines. Each line contains a positive integer, the answer for the corresponding test case.
2
3
1 2 3
4
114 514 1919 810
3
1
Hint
Sample Explanation
For the first test case, happybob can sort the array as . The deletion process is as follows:
| Operation | (after the operation) | Numbers on the ground (after the operation) |
|---|---|---|
| Initial | ||
There are no numbers left on the ground, meaning a total of numbers were deleted.
For the second test case, it can be proven that no matter how you rearrange , you can only delete one number.
Constraints
This problem has multiple test cases.
For of the testdata, it is guaranteed that , . Here is the sum of over all test cases.
Translated by ChatGPT 5