P20282 [CodeChef] CIREQ
提高-
题目描述

​A 1-indexed array is called positive if every element of the array is greater than or equal to the index on which it lies. Formally, an array B of size M is called positive if B_{i} ≥ i for each 1≤ i ≤ M.

For example, the arrays [1], [2, 2], [3, 2, 4, 4] are positive while the arrays [2, 1], [3, 1, 2] are not positive.

You are given an array A containing N integers. You want to distribute all elements of the array into some positive arrays. The elements of a positive array might not occur in the order they appear in the array A.

Find the minimum number of positive arrays that the elements of the array A can be divided into.

Please see the sample cases below for more clarity.

------ Input Format ------

  • The first line of input will contain a single integer T, denoting the number of test cases.
  • Each test case consists of two lines of input.
  • The first line of each test case contains an integer N — the number of elements in the array A.
  • The next line contains $N space-separated integers A_{1}, A_{2},\ldots, A_{N}$ — the elements of array A.

------ Output Format ------

For each test case, output on a new line the minimum number of positive arrays that the elements of the array A can be divided into.
​

------ Constraints ------

$1 ≤ T ≤ 10^{4}$
$1 ≤ N ≤ 10^{5}$
$1 ≤ A_{i} ≤ N$
- The sum of $N$ over all test cases won't exceed $2\cdot 10^{5}$.

----- Sample Input 1 ------
5
3
2 3 3
4
3 1 1 2
3
1 1 1
5
1 2 2 4 5
6
3 2 1 2 2 1

----- Sample Output 1 ------
1
2
3
2
3

----- explanation 1 ------
Test case $1$: The given array is already positive. So the optimal division is $[2,3,3]$.

Test case $2$: One possible division is $[1, 2], [1, 3]$.

Test case $3$: The only possible division is $[1],[1],[1]$.

Test case $4$: One possible division is $[1, 2, 5], [2, 4]$.

Test case $5$: One possible division is $[1, 2, 3], [1], [2,2]$.

输入格式

见题面

输出格式

见题面

样例输入
5 3 2 3 3 4 3 1 1 2 3 1 1 1 5 1 2 2 4 5 6 3 2 1 2 2 1
样例输出
1 2 3 2 3