#K73162. Max Checkpoints

    ID: 33915 Type: Default 1000ms 256MiB

Max Checkpoints

Max Checkpoints

You are given a task to help Xenia maximize the number of checkpoints she can visit. Each checkpoint has a difficulty level. However, when Xenia visits a checkpoint with a certain difficulty, the checkpoint's difficulty increases by 1 which may affect the sequence of checkpoints visited. More formally, you are given an integer \(T\) representing the number of test cases. For each test case, you are given an integer \(N\) and a list of \(N\) integers representing the difficulty levels of the checkpoints.

The strategy is to sort the difficulty levels in non-decreasing order and then traverse the list. Start by visiting the first checkpoint. For each subsequent checkpoint \(i\) (for \(i \ge 2\)), if the current difficulty is strictly greater than the previous checkpoint's difficulty, then Xenia visits that checkpoint and its difficulty is increased by one, i.e., mathematically, if \(a_i > a_{i-1}\) then increment the counter and modify \(a_i\) by replacing it with \(a_i+1\). The final goal is to count how many checkpoints can be visited using this strategy.

It can be summarized by the following pseudo-formula for each test case:

\[ \text{count} = 1 \quad \text{and for } i = 2 \text{ to } N, \quad \text{if } a_i > a_{i-1}\text{ then } \text{count} = \text{count} + 1 \quad \text{and } a_i = a_i + 1. \]

Output the maximum number of checkpoints that can be visited for every test case.

inputFormat

The input is given via standard input (stdin) with the following format:

T
N1
a11 a12 ... a1N1
N2
a21 a22 ... a2N2
...
NT
aT1 aT2 ... aTNT

Here, \(T\) is the number of test cases. For each test case, the first line contains an integer \(N\) (the number of checkpoints), and the second line contains \(N\) space-separated integers representing the corresponding difficulty levels.

outputFormat

For each test case, output a single integer on a new line representing the maximum number of checkpoints Xenia can visit.

## sample
2
5
4 2 6 8 3
3
5 5 5
4

1

</p>