#C6452. Team Division Challenge

    ID: 50214 Type: Default 1000ms 256MiB

Team Division Challenge

Team Division Challenge

You are given two lists of integers representing the stamina and speed of 2n students. Your task is to determine whether it is possible to split them into two teams, each of n students, such that when both lists are sorted in non-decreasing order, the following conditions hold for every index i (0 ≤ i < n):

\(\text{stamina}_{i+n} - \text{stamina}_i \ge s\) and \(\text{speed}_{i+n} - \text{speed}_i \ge s\)

If both conditions are satisfied for every corresponding pair then the answer is YES, otherwise, it is NO.

Note: Sorting is applied separately to the stamina and speed arrays.

inputFormat

The first line contains an integer T denoting the number of test cases.

Each test case begins with a line containing two integers n and s, where n denotes the half of the total number of students (i.e. total students = 2n) and s is the minimum required difference.

The next line contains 2n space-separated integers denoting the stamina values of the students.

The following line contains 2n space-separated integers denoting the speed values of the students.

Input is read from stdin.

outputFormat

For each test case, output a single line containing either YES or NO depending on whether the teams can be divided as required.

Output is written to stdout.

## sample
2
2 4
5 9 1 6
2 8 3 10
3 7
8 15 12 6 9 18
5 14 7 20 10 13
YES

NO

</p>