#C5110. Taco: Non-decreasing Array Validation
Taco: Non-decreasing Array Validation
Taco: Non-decreasing Array Validation
You are given several test cases. For each test case, you are provided with an array of integers.
Your task is to determine whether the array is sorted in non-decreasing order. In other words, for an array \(a_1, a_2, \dots, a_m\), the array is sorted in non-decreasing order if and only if \(a_i \leq a_{i+1}\) for every \(1 \leq i < m\).
Output YES
if the array meets this condition and NO
otherwise.
inputFormat
The input is read from standard input (stdin) and has the following format:
T m1 a11 a12 ... a1m1 m2 a21 a22 ... a2m2 ...
Where:
T
is the number of test cases.- For each test case, the first number is
m
(the number of elements in the array), followed bym
integers representing the array elements.
outputFormat
For each test case, output a single line containing YES
if the array is sorted in non-decreasing order, and NO
otherwise. The result for each test case should be printed in order, each on a new line.
3
5 1 2 3 4 5
4 1 3 2 4
6 10 20 20 30 40 50
YES
NO
YES
</p>