CF1815A Ian and Array Sorting

题目描述

为了感谢 $\textrm{lan}$,$\textrm{Mary}$ 赠送了 $\textrm{lan}$ 一个长度为 $n$ 的序列。为了让他自己看起来聪明,他想要让序列按非递减排序。他可以执行以下操作若干次: + 选择数组中的两个元素 $a_i,a_{i+1}$ ( $1\le i

输入格式

第一行是一个正整数 $t$ ( $1\le t\le 10^4$ ),表示测试数据的数量。 对于每组数据: 第一行是一个正整数 $n$ ( $1\le n\le 3\cdot 10^5$ ),表示序列中有多少元素。 第二行是 $n$ 个正整数 $a_1,a_2,\dots,a_n$ ( $1\le a_i\le 10^9$ ),表示序列 $a$ 的元素。 保证 $n$ 的总和不超过 $3\cdot 10^5$。

输出格式

对于每个测试数据,如果该序列在操作后能按非递减顺序排序,输出 `YES`,否则输出 `NO`。 你可以打印 `YES`,`yEs`,`yes`,`Yes`,这些都是可以被接受的。

说明/提示

For the first test case, we can increase $ a_2 $ and $ a_3 $ both by $ 1 $ . The array is now $ [1, 4, 3] $ . Then we can decrease $ a_1 $ and $ a_2 $ both by $ 1 $ . The array is now $ [0, 3, 3] $ , which is sorted in non-decreasing order. So the answer is "YES". For the second test case, no matter how Ian perform the operations, $ a_1 $ will always be larger than $ a_2 $ . So the answer is "NO" and Ian cannot pretend to be smart. For the third test case, the array is already in non-decreasing order, so Ian does not need to do anything.