cswork / OA打开练习工作台

AmazonOA #360

Count Max Num Teams

估计中等可在线判题

考点(AI 标注)贪心调度原地数组

Each team has exactly teamSize people, and within a team the highest skill minus the lowest skill must not exceed maxDiff. Each person joins at most one team, and some people may not take part. Find the maximum number of teams.

输入格式

The first line contains n teamSize maxDiff and the second line contains n skill values. The original bounds are 1≤teamSize≤n≤100000, 1≤maxDiff≤10^9, 1≤skill[i]≤10^9.

输出格式

Output a single integer, the answer.

样例 1

输入:

6 3 2
3 4 3 1 6 5

输出:

2

样例 2

输入:

3 2 1
1 10 20

输出:

0

样例 3

输入:

3 1 1
4 4 4

输出:

3

样例说明

The outputs of the three public examples are 2; 0; and 3, checked by independent enumeration or direct simulation.