#K82317. Taco Sequence
Taco Sequence
Taco Sequence
You are given T test cases. For each test case, an array of N integers is provided. Your task is to determine whether there exists a triple of indices i, j, and k (with i < j < k
) such that the corresponding elements satisfy the condition:
\( a_i < a_j < a_k \)
If such a triple exists, print YES for that test case; otherwise, print NO.
Note: A valid triple requires that the indices are strictly increasing (i < j < k
) and the values are also strictly increasing.
inputFormat
The input is given via stdin and has the following format:
T N_1 a1 a2 ... aN1 N_2 a1 a2 ... aN2 ... N_T a1 a2 ... aN_T
Where:
T
is the number of test cases.- For each test case, the first line contains an integer
N
, the number of elements in the array. - The next line contains
N
space-separated integers.
outputFormat
For each test case, output a single line containing YES
if there exists three indices i, j, k satisfying i < j < k
and \( a_i < a_j < a_k \), otherwise output NO
.
Output is via stdout.
## sample2
5
1 2 3 4 5
4
5 1 4 3
YES
NO
</p>