欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1705A.Mark the Photographer
Mark the Photographer
Mark is asked to take a group photo of people. The -th person has height units.
To do so, he ordered these people into two rows, the front row and the back row, each consisting of people. However, to ensure that everyone is seen properly, the -th person of the back row must be at least units taller than the -th person of the front row for each between and , inclusive.
Help Mark determine if this is possible.
Input
The first line contains one integer () — the number of test cases. Each test case consists of two lines.
The first line of each test case contains two positive integers and (, ) — the number of people in each row and the minimum difference Mark wants.
The second line of each test case contains positive integers () — the height of each person in units.
Note that the sum of 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 | |||
|---|---|---|---|
| Front |
It works because
- ,
- , and
- .
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.
Samples
3
3 6
1 3 9 10 12 16
3 1
2 5 2 2 2 5
1 2
8 6
YES
NO
YES
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |