CF2114C.Need More Arrays

传统题 时间 2000 ms 内存 256 MiB 5 尝试 1 已通过 1 标签

Need More Arrays

Given an array aa and nn integers. It is sorted in non-decreasing order, that is, aiai+1a_i \le a_{i + 1} for all 1i<n1 \le i \lt n.

You can remove any number of elements from the array (including the option of not removing any at all) without changing the order of the remaining elements. After the removals, the following will occur:

  • a1a_1 is written to a new array;
  • if a1+1<a2a_1 + 1 \lt a_2, then a2a_2 is written to a new array; otherwise, a2a_2 is written to the same array as a1a_1;
  • if a2+1<a3a_2 + 1 \lt a_3, then a3a_3 is written to a new array; otherwise, a3a_3 is written to the same array as a2a_2;
  • \cdots

For example, if a=[1,2,4,6]a=[1, 2, 4, 6], then:

  • a1=1a_1 = 1 is written to the new array, resulting in arrays: [1][1];
  • a1+1=2a_1 + 1 = 2, so a2=2a_2 = 2 is added to the existing array, resulting in arrays: [1,2][1, 2];
  • a2+1=3a_2 + 1 = 3, so a3=4a_3 = 4 is written to a new array, resulting in arrays: [1,2][1, 2] and [4][4];
  • a3+1=5a_3 + 1 = 5, so a4=6a_4 = 6 is written to a new array, resulting in arrays: [1,2][1, 2], [4][4], and [6][6].

Your task is to remove elements in such a way that the described algorithm creates as many arrays as possible. If you remove all elements from the array, no new arrays will be created.

Input

The first line of input contains one integer tt (1t1041 \le t \le 10^4) — the number of test cases.

The first line of each test case contains one integer nn (1n21051 \le n \le 2 \cdot 10^5) — the length of the array.

The second line of each test case contains nn integers a1,a2,,ana_1, a_2, \dots, a_n (1ai1061 \le a_i \le 10^6, aiai+1a_i \le a_{i + 1}) — the elements of the array.

It is guaranteed that the sum of nn across all test cases does not exceed 21052 \cdot 10^5.

Output

For each test case, output one integer — the maximum number of arrays that can be obtained by removing any (possibly zero) number of elements.

Note

In the first example, you can remove a3a_3 and a5a_5, then a=[1,2,4,6]a=[1, 2, 4, 6], the process of forming arrays for it is shown in the statement.

In the second example, you need to remove a2a_2, after which a=[1,3]a = [1, 3], and the arrays [1][1] and [3][3] will be written.

In the third example, no removals are needed; for a=[1,2,2,4]a = [1, 2, 2, 4], the arrays [1,2,2][1, 2, 2] and [4][4] will be written.

Samples

6
6
1 2 3 4 5 6
3
1 2 3
4
1 2 2 4
1
2
3
1 4 8
2
1 1
3
2
2
1
3
1

在线编程 IDE

建议全屏模式获得最佳体验