欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF2062B.Clockwork
Clockwork
You have a sequence of time clocks arranged in a line, where the initial time on the -th clock is . In each second, the following happens in order:
- Each clock's time decreases by . If any clock's time reaches , you lose immediately.
- You can choose to move to an adjacent clock or stay at the clock you are currently on.
- You can reset the time of the clock you are on back to its initial value .
Note that the above events happen in order. If the time of a clock reaches in a certain second, even if you can move to this clock and reset its time during that second, you will still lose.
You can start from any clock. Determine if it is possible to continue this process indefinitely without losing.
Input
The first line of input contains a single integer () — the number of test cases.
For each test case, the first line contains a single integer () — the number of time clocks.
The second line contains integers () — the initial times set on the clocks.
It is guaranteed that the sum of over all test cases does not exceed .
Output
For each test case, print "YES" (without quotes) if it is possible to continue this process indefinitely, or "NO" (without quotes) otherwise.
You can output "YES" and "NO" in any case (for example, strings "yEs", "yes" and "Yes" will be recognized as a positive response).
Note
In the first test case, you can move back and forth between the two clocks, resetting them repeatedly.
In the third test case, assuming that you start from clock and follow the strategy below:
Initially, .
- becomes . You move to clock and reset its time, resulting in .
- becomes . You move to clock and reset its time, resulting in .
- becomes . You move to clock and reset its time, resulting in .
- becomes . You move to clock , but you lose because reaches .
It can be proven that no other strategy allows you to continue this process indefinitely.
Samples
5
2
4 10
2
2 2
3
4 10 5
3
5 3 5
5
12 13 25 17 30
YES
NO
NO
YES
YES
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |