Codeforces Round 807 (Div. 2)
A
Mark the Photographer
Codeforces
800
原题
←B →
翻译中…

Mark is asked to take a group photo of $2n$ people. The $i$-th person has height $h_i$ units.

翻译中…

To do so, he ordered these people into two rows, the front row and the back row, each consisting of $n$ people. However, 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.

翻译中…

Help Mark determine if this is possible.

翻译中…

Input

翻译中…

The first line contains one integer $t$ ($1\leq t\leq 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$ ($1\leq n\leq 100$, $1\leq x\leq 10^3$) — the number of people in each row and the minimum difference Mark wants.

翻译中…

The second line of each test case contains $2n$ positive integers $h_1,h_2,\ldots,h_{2n}$ ($1\leq h_i\leq 10^3$) — the height of each person in units.

翻译中…

Note that the sum of $n$ over all test cases is not bounded.

翻译中…

Output

翻译中…

For each test case, print a single line containing "YES" if Mark could arrange people satisfying his condition and "NO" otherwise.

翻译中…

You may print each letter in any case (for example, YES, Yes, yes, yEs will all be recognized as positive answers).

翻译中…

Note

翻译中…

In the first test case, one possible order is to have the third, fifth, and sixth person on the back row and the second, first, and fourth on the front row. The heights of the people will look like this.

翻译中…

Back$9$$12$$16$Front$3$$1$$10$

翻译中…

It works because

翻译中…
  • $h_3-h_2 = 9-3 \geq 6$,
  • $h_5-h_1 = 12-1\geq 6$, and
  • $h_6-h_4 = 16-10\geq 6$.
翻译中…

In the second test case, it can be shown there is no way to order people in a way that satisfies the condition.

翻译中…

In the third test case, the only way to arrange people to satisfy the condition is to have the first person on the back row and the second person on the front row.

翻译中…

样例

Input #1
3
3 6
1 3 9 10 12 16
3 1
2 5 2 2 2 5
1 2
8 6
Output #1
YES
NO
YES
InputCopy OutputCopy
题目信息
题号
1705A
时间限制
1 s
内存限制
256 MB
标签
贪心
排序

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。