309602: CF1705A. Mark the Photographer

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Mark the Photographer

题意翻译

`Mark` 被要求拍摄一张 $2 \times n$ 个人的照片,第 $i$ 个人的身高是 $h_i$,他将这些人排成两排,即前后两排,每排 $n$ 个人,但后排的第 $j$ 个人必须比前排的第 $j$ 个人高 $x$ 个单位,你需要帮助 `Mark` 确定这是否可以做到,如果可以输出`YES`,否则输出`NO`。

题目描述

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.

输入输出格式

输入格式


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.

输出格式


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 - $ 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

题意翻译

`Mark` 被要求拍摄一张 $2 \times n$ 个人的照片,第 $i$ 个人的身高是 $h_i$,他将这些人排成两排,即前后两排,每排 $n$ 个人,但后排的第 $j$ 个人必须比前排的第 $j$ 个人高 $x$ 个单位,你需要帮助 `Mark` 确定这是否可以做到,如果可以输出`YES`,否则输出`NO`。

Output

题目大意:
`Mark` 被要求拍摄一张 $2 \times n$ 个人的照片,第 $i$ 个人的身高是 $h_i$,他将这些人排成两排,即前后两排,每排 $n$ 个人,但后排的第 $j$ 个人必须比前排的第 $j$ 个人高 $x$ 个单位,你需要帮助 `Mark` 确定这是否可以做到,如果可以输出`YES`,否则输出`NO`。

输入输出数据格式:
输入格式:
- 第一行包含一个整数 $t$ ( $1 \leq t \leq 100$ ) — 测试用例的数量。每个测试用例包含两行。
- 每个测试用例的第一行包含两个正整数 $n$ 和 $x$ ( $1 \leq n \leq 100$ , $1 \leq x \leq 10^3$ ) — 每排的人数和Mark想要的最小高度差。
- 每个测试用例的第二行包含 $2n$ 个正整数 $h_1, h_2, \ldots, h_{2n}$ ( $1 \leq h_i \leq 10^3$ ) — 每个人的身高单位。
- 注意,所有测试用例的 $n$ 之和没有限制。

输出格式:
- 对于每个测试用例,如果Mark可以安排人们满足他的条件,则打印一行包含"YES",否则打印"NO"。
- 你可以以任何大小写打印每个字母(例如,YES, Yes, yes, yEs都将被识别为肯定答案)。题目大意: `Mark` 被要求拍摄一张 $2 \times n$ 个人的照片,第 $i$ 个人的身高是 $h_i$,他将这些人排成两排,即前后两排,每排 $n$ 个人,但后排的第 $j$ 个人必须比前排的第 $j$ 个人高 $x$ 个单位,你需要帮助 `Mark` 确定这是否可以做到,如果可以输出`YES`,否则输出`NO`。 输入输出数据格式: 输入格式: - 第一行包含一个整数 $t$ ( $1 \leq t \leq 100$ ) — 测试用例的数量。每个测试用例包含两行。 - 每个测试用例的第一行包含两个正整数 $n$ 和 $x$ ( $1 \leq n \leq 100$ , $1 \leq x \leq 10^3$ ) — 每排的人数和Mark想要的最小高度差。 - 每个测试用例的第二行包含 $2n$ 个正整数 $h_1, h_2, \ldots, h_{2n}$ ( $1 \leq h_i \leq 10^3$ ) — 每个人的身高单位。 - 注意,所有测试用例的 $n$ 之和没有限制。 输出格式: - 对于每个测试用例,如果Mark可以安排人们满足他的条件,则打印一行包含"YES",否则打印"NO"。 - 你可以以任何大小写打印每个字母(例如,YES, Yes, yes, yEs都将被识别为肯定答案)。

加入题单

算法标签: