#K9106. Minimum Age Groups

    ID: 37891 Type: Default 1000ms 256MiB

Minimum Age Groups

Minimum Age Groups

You are given T test cases. For each test case, you are given an integer N (the number of people) and an integer K (the maximum allowed age difference within a group). You are also provided with a list of N integer ages. Your task is to determine the minimum number of groups such that in each group, the difference between the oldest and the youngest person is at most $$K$$.

The problem can be formalized as follows: for each test case, partition the sorted ages into the minimum number of segments so that for each segment $$S$$, if min(S) and max(S) denote the smallest and largest age in $$S$$ respectively, then:

max(S)min(S)K\text{max}(S) - \text{min}(S) \le K

Print the result for each test case on a separate line.

inputFormat

The first line of input contains an integer T, the number of test cases. Each test case is described as follows:

  1. The first line of each test case contains two integers N and K separated by a space.
  2. The second line contains N space-separated integers representing the ages.

outputFormat

For each test case, print a single line containing one integer – the minimum number of groups required.

## sample
2
6 5
2 3 10 7 13 8
5 10
1 12 23 34 45
2

5

</p>