cswork / OAOpen practice workspace

AmazonOA #360

Count Max Num Teams

Estimated MediumJudge-ready

Topics (AI-labelled)GreedyIn-place Arrays

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.

Input

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

Output a single integer, the answer.

Example 1

Input:

6 3 2
3 4 3 1 6 5

Output:

2

Example 2

Input:

3 2 1
1 10 20

Output:

0

Example 3

Input:

3 1 1
4 4 4

Output:

3

Example notes

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

Editorial

Loading solution…