AmazonOA #242
Group Students (AS Intern, it may apply to other interns)
估计简单可在线判题
Divide all students into classes so that any two students in the same class differ in skill by at most maxSpread; find the minimum number of classes. Groups do not need to keep original indices adjacent, and different students with the same skill must all be placed.
输入格式
The first line contains n maxSpread; the second line contains the skills. The original text gives n≤100000 and a skill upper bound of 10^9, but the lower bounds were damaged in typesetting and no bound was given for maxSpread; this site explicitly uses 1≤n≤100000, 1≤skill≤10^9, 0≤maxSpread≤10^9.
输出格式
Output a single integer, the answer.
样例 1
输入:
5 2
1 4 7 3 4
输出:
3
样例 2
输入:
3 1
1 2 3
输出:
2
样例 3
输入:
3 0
7 7 7
输出:
1
样例说明
The answers are 3, 2 and 1. Adjacent skill differences all being ≤1 does not mean 1,2,3 can share a class.