Getting Started With Competitive Programming · Instructor: Prof. Neeldhara Misra
You have to take a group photo of 2N people. The i-th person has height H[i] units. You organize these people into two two rows consisting of N people each. To ensure that everyone is seen properly, the j-th person of the back row must be at least X units taller than the j-th person of the front row for each j between 1 and N, inclusive. Is this possible? Input The first line contains one integer t (1≤t≤100) — the number of test cases. Each test case consists of two lines. The first line of each test case contains two positive integers N and X (N is between 1 and 100; X is between 1 and 1000) — the number of people in each row and the minimum difference you want. The second line of each test case contains 2N positive integers h[1],h[2],…,h[2n] (each h[i] is between 1 and 1000) — the height of each person in units. Output For each test case, print a single line containing "YES" if it is possible to arrange people satisfying the condition described in the problem statement above and "NO" otherwise. Example Input: 3 3 6 1 3 9 10 12 16 3 1 2 5 2 2 2 5 1 2 8 6 Output YES NO YES