#K40292. Taco Layer Arrangement
Taco Layer Arrangement
Taco Layer Arrangement
You are given several test cases. In each test case, Chef has a taco with multiple layers, each having a specific sweetness level. Chef's policy is that the layers must be arranged in non-decreasing order of sweetness from top to bottom. In other words, for a given sequence of layers with sweetness values \(a_1, a_2, \dots, a_N\), the arrangement is valid if \(a_1 \le a_2 \le \cdots \le a_N\).
Your task is to determine for each test case whether the given sweetness order is valid. If it is, print YES
; otherwise, print NO
.
Input Format: The first line contains an integer \(T\), the number of test cases. For each test case, the first line contains an integer \(N\) (the number of layers), followed by a line with \(N\) space-separated integers representing the sweetness levels.
Output Format: For each test case, output a single line containing YES
if the sequence is non-decreasing, or NO
otherwise.
inputFormat
The first line contains an integer \(T\) representing the number of test cases. Each test case consists of two lines:
- The first line contains an integer \(N\), the number of layers.
- The second line contains \(N\) space-separated integers representing the sweetness levels of the layers.
Input is read from stdin.
outputFormat
For each test case, output on a new line YES
if the layers are arranged in non-decreasing order, or NO
otherwise. The output is written to stdout.
4
3
1 2 3
3
1 3 2
2
5 5
4
1 1 1 1
YES
NO
YES
YES
</p>