欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1923B.Monsters Attack!
Monsters Attack!
You are playing a computer game. The current level of this game can be modeled as a straight line. Your character is in point of this line. There are monsters trying to kill your character; the -th monster has health equal to and is initially in the point .
Every second, the following happens:
- first, you fire up to bullets at monsters. Each bullet targets exactly one monster and decreases its health by . For each bullet, you choose its target arbitrary (for example, you can fire all bullets at one monster, fire all bullets at different monsters, or choose any other combination). Any monster can be targeted by a bullet, regardless of its position and any other factors;
- then, all alive monsters with health or less die;
- then, all alive monsters move point closer to you (monsters to the left of you increase their coordinates by , monsters to the right of you decrease their coordinates by ). If any monster reaches your character (moves to the point ), you lose.
Can you survive and kill all monsters without letting any of them reach your character?
Input
The first line of the input contains one integer () — the number of test cases.
Each test case consists of three lines:
- the first line contains two integers and (; );
- the second line contains integers ();
- the third line contains integers ($-n \le x_1 \lt x_2 \lt x_3 \lt \dots \lt x_n \le n$; ).
Additional constraint on the input: the sum of over all test cases does not exceed .
Output
For each test case, print YES if you can kill all monsters before they reach your character, or NO otherwise.
You can output each letter of the answer in any case (upper or lower). For example, the strings yEs, yes, Yes, and YES will all be recognized as positive responses.
Note
In the first example, you can act as follows:
- during the -st second, fire bullet at the -st monster and bullet at the -rd monster. Then the -st monster dies, the -nd and the -rd monster move closer;
- during the -nd second, fire bullets at the -nd monster. Then the -nd monster dies, the -rd monster moves closer;
- during the -rd second, fire bullets at the -rd monster. Then the -rd monster dies.
In the second example, you can fire only bullet, so you can kill only one of the two monsters during the -st second. Then, the remaining monster moves closer and kills your character.
Samples
5
3 2
1 2 3
-1 2 3
2 1
1 1
-1 1
4 10
3 4 2 5
-3 -2 1 3
5 3
2 1 3 2 5
-3 -2 3 4 5
2 1
1 2
1 2
YES
NO
YES
YES
NO
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |