CF2244B.Nikita and Books

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

As is well known, Nikita loves reading. Today, he made a mess in his room and arranged his books into nn stacks in a row, numbered from 11 to nn from left to right. The ii-th stack contains aia_i books. This arrangement is called neat if, in every stack except the rightmost one, the number of books is strictly less than in the stack to its right; that is, the array aa is strictly increasing.

Yura wants to make the arrangement neat by performing the following operation any number of times:

  1. Choose a stack ii such that 1≤i<n1 \le i \lt n and ai>1a_i \gt 1.
  2. Take 11 book from the top of stack ii, so aia_i decreases by 11.
  3. Put this book on top of stack i+1i + 1, so ai+1a_{i+1} increases by 11.

Determine whether Yura can make the arrangement neat.

众所周知,尼基塔非常喜欢阅读。今天,他把房间弄得一团糟,将他的书排成了从左到右编号为 11 到 nn 的 nn 堆。第 ii 堆包含 aia_i 本书。若除最右边一堆外,每一堆的书本数量都严格小于其右边一堆的数量(即数组 aa 是严格递增的),则称该排列是“整齐的”。

尤拉希望通过执行以下操作任意多次,使该排列变得整齐:

  1. 选择一个满足 1≤i<n1 \le i \lt n 且 ai>1a_i \gt 1 的堆 ii;
  2. 从堆 ii 的顶部取走 11 本书,使得 aia_i 减少 11;
  3. 将这本书放在堆 i+1i + 1 的顶部,使得 ai+1a_{i+1} 增加 11。

请判断尤拉是否能使该排列变得整齐。

输入格式

The first line contains a single integer tt (1≤t≤1041 \le t \le 10^4) — the number of test cases.

The first line of each test case contains a single integer nn (1≤n≤2⋅1051 \le n \le 2 \cdot 10^5) — the number of stacks.

The second line of each test case contains nn integers aia_i (1≤ai≤1091 \le a_i \le 10^9) — the initial number of books in each stack.

It is guaranteed that the sum of nn over all test cases does not exceed 2⋅1052 \cdot 10^5.

第一行包含一个整数 tt(1≤t≤1041 \le t \le 10^4)——测试用例的数量。

每个测试用例的第一行包含一个整数 nn(1≤n≤2⋅1051 \le n \le 2 \cdot 10^5)——堆栈的数量。

每个测试用例的第二行包含 nn 个整数 aia_i(1≤ai≤1091 \le a_i \le 10^9)——每堆初始的书本数量。

保证所有测试用例的 nn 之和不超过 2⋅1052 \cdot 10^5。

输出格式

For each test case, output "YES" if Yura can make the arrangement neat, and "NO" otherwise.

You may output each letter in any case (lowercase or uppercase). For example, the strings "yEs", "yes", "Yes", and "YES" will be accepted.

对于每个测试用例,如果尤拉能使排列变得整齐,则输出 “YES”,否则输出 “NO”。

您可以以任意大小写形式输出每个字母(小写或大写)。例如,字符串 “yEs”、“yes”、“Yes” 和 “YES” 均可被接受。

输入输出样例

  • 输入#1

    7
    3
    1 2 3
    3
    1 1 2
    3
    10 1 1
    3
    2 2 2
    4
    1 4 2 2
    5
    8 2 8 1 8
    4
    1 1 3 5

    输出#1

    YES
    NO
    YES
    YES
    NO
    YES
    NO

说明/提示

null

输入解题思路,AI测评打分。不知道怎么写?

首页