Uniform Cohort Batches

Medium
ArraySortingGreedyContest
A bootcamp must split n students into batches by skill level. You are given each student's skill and two limits: d, the maximum allowed skill spread inside a batch (the largest skill minus the smallest skill in that batch must be at most d), and c, the maximum number of students per batch. You may place any students together in a batch regardless of their original order. Every student must belong to exactly one batch. Print the minimum number of batches needed so that both limits are respected in every batch. Input format: - First line: n d c - Second line: n integers (the skills) Print a single integer.

Constraints

1 <= n <= 10^5
0 <= d <= 10^9
1 <= c <= n
-10^9 <= skill[i] <= 10^9

Sample tests

Sample 1

Sample 2

Sign in to submit