欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1486A.Shifting Stacks
Shifting Stacks
You have stacks of blocks. The -th stack contains blocks and it's height is the number of blocks in it. In one move you can take a block from the -th stack (if there is at least one block) and put it to the -th stack. Can you make the sequence of heights strictly increasing?
Note that the number of stacks always remains : stacks don't disappear when they have blocks.
Input
First line contains a single integer — the number of test cases.
The first line of each test case contains a single integer . The second line of each test case contains integers — starting heights of the stacks.
It's guaranteed that the sum of all does not exceed .
Output
For each test case output YES if you can make the sequence of heights strictly increasing and NO otherwise.
You may print each letter in any case (for example, YES, Yes, yes, yEs will all be recognized as positive answer).
Note
In the first test case there is no need to make any moves, the sequence of heights is already increasing.
In the second test case we need to move one block from the first stack to the second. Then the heights become .
In the third test case we could move one block from the first stack to the second and then from the second to the third, which would make the heights .
In the fourth test case we can't make a move, but the sequence is not increasing, so the answer is NO.
In the fifth test case we can only make one move (from the second to the third stack), which would make the heights . Both and are not increasing sequences, so the answer is NO.
Samples
6
2
1 2
2
1 0
3
4 4 4
2
0 0
3
0 1 0
4
1000000000 1000000000 1000000000 1000000000
YES
YES
YES
NO
NO
YES
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |