cswork / OA打开练习工作台

Akuna CapitalOA #19

An Evening of Movies

估计中等可在线判题

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

Pick movies from the library and arrange them in any order; the runtimes of adjacent movies must be equal or increase by exactly 1 minute, and no movie may be watched twice. Find the maximum number of movies that can be watched.

输入格式

The first line contains n; the second line contains n positive integers runtime[i]. The original gives no value bounds; this site adds 1≤n≤100000, 1≤runtime[i]≤10^9.

输出格式

Output the maximum number of movies that can be watched.

样例 1

输入:

5
8 4 5 7 4

输出:

3

样例 2

输入:

3
1 1 1

输出:

3

样例 3

输入:

5
1 2 2 3 5

输出:

4