Codeforces Round 1039 (Div. 2)
C
Leftmost Below
Codeforces
1200
原题
← BD →
翻译中…

Consider an array $a_1, \ldots, a_n$. Initially, $a_i = 0$ for every $i$.

翻译中…

You can do operations of the following form.

翻译中…
  • You choose an integer $x$ greater than $\min(a)$.
  • Then, $i$ is defined as the minimum index such that $a_i \lt x$. In other words, $i$ is the unique integer between $1$ and $n$ inclusive such that $a_i \lt x$ and $a_j \geq x$ for every $1 \leq j \leq i-1$.
  • Finally, $a_i$ is incremented by $x$.
翻译中…

For example, if $a = [6, 8, 2, 1]$ and you choose $x = 6$, then $i$ will be equal to $3$ (since $a_1 \geq 6$, $a_2 \geq 6$, and $a_3 \lt 6$) and $a$ will become $[6, 8, 8, 1]$.

翻译中…

You can do as many operations as you want. Can you reach a target array $b_1, \ldots, b_n$?

翻译中…

Input

翻译中…

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 10\,000$). The description of the test cases follows.

翻译中…

The first line of each test case contains a single integer $n$ ($2 \leq n \leq 200\,000$).

翻译中…

The second line of each test case contains $n$ integers $b_1, b_2, \ldots, b_n$ ($1 \le b_i \le 10^9$).

翻译中…

The sum of $n$ over all test cases does not exceed $200\,000$.

翻译中…

Output

翻译中…

For each test case, print YES if you can reach the target array and NO otherwise.

翻译中…

You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.

翻译中…

Note

翻译中…

In the first test case, we can do the following sequence of operations:

翻译中…
  • we choose $x=2$, $a$ becomes $[2, 0, 0, 0]$
  • we choose $x=2$, $a$ becomes $[2, 2, 0, 0]$
  • we choose $x=3$, $a$ becomes $[5, 2, 0, 0]$
  • we choose $x=4$, $a$ becomes $[5, 6, 0, 0]$
  • we choose $x=1$, $a$ becomes $[5, 6, 1, 0]$
  • we choose $x=1$, $a$ becomes $[5, 6, 1, 1]$
翻译中…

In the second test case, we can prove there is no way to reach $[3, 1, 2]$.

翻译中…

样例

Input #1
4
4
5 6 1 1
3
3 1 2
3
40 60 90
2
1 1
Output #1
YES
NO
NO
YES
InputCopy OutputCopy
题目信息
题号
2128C
时间限制
2 s
内存限制
256 MB
标签
贪心
数学

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