#C6296. Minimum Group Partitioning

    ID: 50040 Type: Default 1000ms 256MiB

Minimum Group Partitioning

Minimum Group Partitioning

You are given n participants with scores and a threshold k. The task is to partition the participants into the minimum number of groups such that in each group, the difference between the highest and lowest scores does not exceed $k$ (i.e. \(\text{max} - \text{min} \le k\)).

More formally, given a list of n integers representing scores, sort the scores and then form groups by taking consecutive scores. For each group, if \(s_i\) is the first score in the group and \(s_j\) the subsequent scores, then the group can include all scores for which \(s_j - s_i \le k\). Your goal is to determine the minimum number of such groups required.

Input and Output through Standard I/O

inputFormat

The input is given via standard input (stdin) in the following format:

 
score1 score2 ... scoren

Where n is the number of participants, k is the maximum allowed difference within a group, and the next line contains n integer scores separated by spaces.

outputFormat

Output a single integer representing the minimum number of groups required. The result should be written to standard output (stdout).

## sample
6 3
10 20 30 40 50 60
6