CF2060D Subtract Min Sort
题目描述
给定一个由 $n$ 个正整数组成的序列 $a$。
可以执行任意次以下操作:
- 选择 $i$,将 $a_i$ 和 $a_{i+1}$ 减去 $\min(a_i,a_{i+1})$。
问能否通过操作使序列单调不降。
输入格式
第一行一个正整数 $T(1\le T\le10^4)$ 表示一共有 $T$ 组数据。
每组数据包含 $2$ 行。
每组数据的第一行,一个正整数 $n(2\le n\le2\times10^5)$,表示序列长度。
每组数据的第二行,$n$ 个正整数 $a_1,a_2,a_3,\dots,a_n(1\le a_i\le10^9)$。
所有 $n$ 的和不超过 $2\times10^5$。
输出格式
如果可以,输出 `Yes`,否则输出 `No`。不区分大小写。
说明/提示
In the first test case, the array is already sorted.
In the second test case, we can show that it is impossible.
In the third test case, after performing an operation on $ i=1 $ , the array becomes $ [0,1,2,3] $ , which is now in nondecreasing order.