AmazonOA #2
Group Students
估计中等可在线判题
Given each student's skill value, assign all students to some number of non-empty classes. Within each class, the difference between the highest and lowest skill values must not exceed maxSpread. Find the minimum number of classes; students in the same class can be chosen freely and need not be contiguous in the original array.
输入格式
The first line contains n maxSpread (1≤n≤100000, 0≤maxSpread≤10⁹), and the second line contains n skill values (1..10⁹).
输出格式
Output a single integer, the answer required by the problem.
样例 1
输入:
4 3
4 8 1 7
输出:
2
样例 2
输入:
3 0
5 5 5
输出:
1
样例 3
输入:
3 1
1 3 5
输出:
3
样例说明
Example 1 can be split into two classes, [1,4] and [7,8], with spans 3 and 1.