cswork / OA打开练习工作台

IBMOA #3

Find Max Team Size

估计简单可在线判题

考点(AI 标注)原地数组哈希计数

Select as many students as possible such that, after sorting by skill, any two adjacent students differ by 0 or 1. The team may span several consecutive skill values; the team's maximum minus minimum is not required to be ≤1.

输入格式

The first line contains n, and the second line contains the skills. On this site 1≤n≤200000, −10^9≤skill≤10^9.

输出格式

Output one integer, the answer.

样例 1

输入:

5
10 12 13 9 14

输出:

3

样例 2

输入:

4
1 2 3 4

输出:

4

样例 3

输入:

3
5 5 7

输出:

2

样例说明

The examples give 3, 4 and 2 respectively. The source editorial only counts two adjacent values, which conflicts with the statement body and the first example; this site corrects it according to the body.