#K4981. Reversed Non-Decreasing Sequence

    ID: 28725 Type: Default 1000ms 256MiB

Reversed Non-Decreasing Sequence

Reversed Non-Decreasing Sequence

In this problem, you are given T test cases. For each test case, you are provided with an integer n and a list of n integers. Your task is to reverse the list and determine whether the reversed list is non-decreasing. A sequence (a_1, a_2, \dots, a_n) is non-decreasing if it satisfies (a_i \leq a_{i+1}) for all (1 \leq i < n). If the condition holds, print “YES”, otherwise print “NO”.

inputFormat

The input is read from standard input (stdin). The first line contains an integer T (the number of test cases). Each test case consists of two lines. The first line of each test case contains a single integer n ((1 \leq n \leq 10^5)), which represents the number of elements in the list. The second line contains n space-separated integers.

outputFormat

For each test case, output a single line to standard output (stdout) with either "YES" if the reversed list is non-decreasing, or "NO" otherwise.## sample

2
4
1 2 3 4
5
5 4 3 3 2
NO

YES

</p>