AtCoder Regular Contest 185
B
+1 and -1
AtCoder
⌀ 1332
原题
← AC →
翻译中…

Problem Statement

翻译中…

You are given an integer sequence $A = (A_1, A_2, \dots, A_N)$ of length $N$. You can perform the following operation any number of times, possibly zero:

翻译中…
  • Choose an integer pair $(i, j)$ satisfying $1 \leq i \lt j \leq N$, and replace $A_i$ with $A_i + 1$ and $A_j$ with $A_j - 1$.
翻译中…

Determine whether it is possible to make $A$ a non-decreasing sequence through the operations.

翻译中…

You are given $T$ test cases. Solve each of them.

翻译中…

Constraints

翻译中…
  • $1 \leq T \leq 2 \times 10^5$
  • $2 \leq N \leq 2 \times 10^5$
  • $0 \leq A_i \leq 10^9$
  • The sum of $N$ over all test cases is at most $2 \times 10^5$.
  • All input values are integers.
翻译中…

Input

翻译中…

The input is given from Standard Input in the following format. Here, $\mathrm{case}_i$ denotes the $i$-th test case.

翻译中…

T
\mathrm{case}_1
\mathrm{case}_2
\vdots
\mathrm{case}_T

翻译中…

Each test case is given in the following format:

翻译中…

N
A_1 A_2 \dots A_N

翻译中…

Output

翻译中…

Print $T$ lines. The $i$-th line should contain the answer for the $i$-th test case. For each test case, if it is possible to make $A$ a non-decreasing sequence through the operations, print Yes; otherwise, print No.

翻译中…

样例

Input #1
3
3
1 7 5
2
9 0
10
607 495 419 894 610 636 465 331 925 724
Output #1
Yes
No
Yes
In the first test case, you can make $A$ into a non-decreasing sequence by performing the following operations: - Choose $(i, j) = (1, 2)$. After the operation, $A$ is $(2, 6, 5)$. - Choose $(i, j) = (1, 2)$. After the operation, $A$ is $(3, 5, 5)$. In the second test case, you cannot make $A$ into a non-decreasing sequence no matter how you perform the operations.
题目信息
题号
arc185_b
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。