Ethflow Round 1 (Codeforces Round 1001, Div. 1 + Div. 2)
B
Clockwork
Codeforces
900
原题
← AC →
翻译中…

You have a sequence of $n$ time clocks arranged in a line, where the initial time on the $i$-th clock is $a_i$. In each second, the following happens in order:

翻译中…
  • Each clock's time decreases by $1$. If any clock's time reaches $0$, 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 $a_i$.
翻译中…

Note that the above events happen in order. If the time of a clock reaches $0$ 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 $t$ ($1 \leq t \leq 10^4$) — the number of test cases.

翻译中…

For each test case, the first line contains a single integer $n$ ($2 \leq n \leq 5 \cdot 10^5$) — the number of time clocks.

翻译中…

The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \leq a_i \leq 10^9$) — the initial times set on the clocks.

翻译中…

It is guaranteed that the sum of $n$ over all test cases does not exceed $5\cdot 10^5$.

翻译中…

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 $1$ and follow the strategy below:

翻译中…

Initially, $a=[4,10,5]$.

翻译中…
  1. $a$ becomes $[3, 9, 4]$. You move to clock $2$ and reset its time, resulting in $a=[3, 10, 4]$.
  2. $a$ becomes $[2, 9, 3]$. You move to clock $3$ and reset its time, resulting in $a=[2, 9, 5]$.
  3. $a$ becomes $[1, 8, 4]$. You move to clock $2$ and reset its time, resulting in $a=[1, 10, 4]$.
  4. $a$ becomes $[0, 9, 3]$. You move to clock $1$, but you lose because $a_1$ reaches $0$.
翻译中…

It can be proven that no other strategy allows you to continue this process indefinitely.

翻译中…

样例

Input #1
5
2
4 10
2
2 2
3
4 10 5
3
5 3 5
5
12 13 25 17 30
Output #1
YES
NO
NO
YES
YES
InputCopy OutputCopy
题目信息
题号
2062B
时间限制
1.5 s
内存限制
512 MB
标签
贪心
数学

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