#K86677. Team Pairing Challenge
Team Pairing Challenge
Team Pairing Challenge
You are given a set of employees with their respective skill levels. Your task is to form as many teams as possible under the following condition:
- Each team is composed of exactly 2 employees.
- The absolute difference between the skill levels of the two employees in a team must not exceed \(K\).
Given \(N\) employees and their skill levels, determine the maximum number of teams that can be formed.
Note: Each employee can be part of at most one team.
inputFormat
The first line of input contains two integers \(N\) and \(K\) where \(N\) is the number of employees and \(K\) is the maximum allowed absolute difference in skill levels for a team.
The second line contains \(N\) space-separated integers representing the skill levels of the employees.
Input is taken from standard input (stdin).
outputFormat
Output a single integer — the maximum number of teams that can be formed meeting the constraint. The answer should be written to standard output (stdout).
## sample6 3
1 3 5 6 7 9
3
</p>