欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1466B.Last minute enhancements
Last minute enhancements
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 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 notes in the song, she can either leave it as it is or increase it by .
Given the song as a sequence of integers describing the notes, find out the maximal, achievable diversity.
Input
The input consists of multiple test cases. The first line contains an integer () — the number of test cases. Then test cases follow, each one is described in two lines.
In the first line of each test case there is a single integer () denoting the length of the song. The next line contains a sequence of integers $(1 \leq x_1 \leq x_2 \leq \ldots \leq x_n \leq 2 \cdot n)$, describing the song.
The sum of over all test cases does not exceed .
Output
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.
Note
In the first test case, Euterpe can increase the second, fifth and sixth element to obtain the sequence $1, \underline{3}, 2, 2, \underline{6}, \underline{7}$, which has different elements (increased elements are underlined).
In the second test case, Euterpe can increase the first element to obtain the sequence , which has different elements.
In the third test case, Euterpe can increase the second, fifth and sixth element to obtain the sequence $1, \underline{2}, 3, 4, \underline{5}, \underline{6}$, which has different elements.
Samples
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
5
2
6
1
3
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |