#P11199. Dance Partner Pairing

    ID: 13265 Type: Default 1000ms 256MiB

Dance Partner Pairing

Dance Partner Pairing

There are \(2N\) students in a class, where the height of the \(i\)-th student (\(1 \le i \le 2N\)) is given as \(A_i\). For an upcoming physical education class, the students need to be paired into \(N\) groups for a dance. In order to have a graceful dance, the absolute height difference between the two students in each pair must be at most \(D\). Given the heights of the students, determine whether it is possible to form \(N\) pairs such that every pair has a height difference not exceeding \(D\).

Note: It is allowed to rearrange the students arbitrarily before pairing.

inputFormat

The first line contains two integers \(N\) and \(D\) (where \(N\) is half the number of students and \(D\) is the maximum allowed height difference).

The second line contains \(2N\) integers \(A_1, A_2, \ldots, A_{2N}\) representing the heights of the students.

outputFormat

Output a single line containing "YES" if it is possible to pair the students as required; otherwise, output "NO".

sample

1 1
1 2
YES

</p>