CF1466B.Last minute enhancements

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Athenaeus has just finished creating his latest musical composition and will present it tomorrow to the people of Athens. Unfortunately, the melody is rather dull and highly likely won't be met with a warm reception.

His song consists of nn notes, which we will treat as positive integers. The diversity of a song is the number of different notes it contains. As a patron of music, Euterpe watches over composers and guides them throughout the process of creating new melodies. She decided to help Athenaeus by changing his song to make it more diverse.

Being a minor goddess, she cannot arbitrarily change the song. Instead, for each of the nn notes in the song, she can either leave it as it is or increase it by 11 .

Given the song as a sequence of integers describing the notes, find out the maximal, achievable diversity.

输入格式

The input consists of multiple test cases. The first line contains an integer tt ( 1t100001 \leq t \leq 10\,000 ) — the number of test cases. Then tt test cases follow, each one is described in two lines.

In the first line of each test case there is a single integer nn ( 1n1051 \leq n \leq 10^5 ) denoting the length of the song. The next line contains a sequence of nn integers x1,x2,,xnx_1, x_2, \ldots, x_n (1x1x2xn2n)(1 \leq x_1 \leq x_2 \leq \ldots \leq x_n \leq 2 \cdot n) , describing the song.

The sum of nn over all test cases does not exceed 10510^5 .

输出格式

For each test case, you should output a single line containing precisely one integer, the maximal diversity of the song, i.e. the maximal possible number of different elements in the final sequence.

输入输出样例

  • 输入#1

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

    输出#1

    5
    2
    6
    1
    3

说明/提示

In the first test case, Euterpe can increase the second, fifth and sixth element to obtain the sequence 1,3,2,2,6,71, \underline{3}, 2, 2, \underline{6}, \underline{7} , which has 55 different elements (increased elements are underlined).

In the second test case, Euterpe can increase the first element to obtain the sequence 5,4\underline{5}, 4 , which has 22 different elements.

In the third test case, Euterpe can increase the second, fifth and sixth element to obtain the sequence 1,2,3,4,5,61, \underline{2}, 3, 4, \underline{5}, \underline{6} , which has 66 different elements.

首页