CF1705A.Mark the Photographer
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Mark is asked to take a group photo of 2n people. The i -th person has height hi 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.
输入格式
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 ( 1≤n≤100 , 1≤x≤103 ) — the number of people in each row and the minimum difference Mark wants.
The second line of each test case contains 2n positive integers h1,h2,…,h2n ( 1≤hi≤103 ) — the height of each person in units.
Note that the sum of n over all test cases is not bounded.
输出格式
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).
输入输出样例
输入#1
3 3 6 1 3 9 10 12 16 3 1 2 5 2 2 2 5 1 2 8 6
输出#1
YES NO YES
说明/提示
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
- h3−h2=9−3≥6 ,
- h5−h1=12−1≥6 , and
- h6−h4=16−10≥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.