luogu#P4728. [HNOI2009] 双递增序列
[HNOI2009] 双递增序列
Problem Description
Consider a sequence of even length . We call this sequence good if and only if there exists a partition of into two sets and $V=\{ a_{j_1}, a_{j_2}, \dots, a_{j_{n/2}} \}=\{ a_1, a_2, \dots, a_n \}-U$, such that , , , and .
For example, the sequence is a good sequence, because it can be split into and . However, the sequence is not a good sequence.
Now, for several given sequences, please determine whether each of them is a good sequence.
Input Format
The first line contains only one integer , indicating that you need to judge sequences.
The next lines give these sequences. Each sequence is given on one line: the first number is an even integer , indicating the length of the sequence, and the following integers are the elements of the sequence . Numbers on the same line are separated by a single space.
Output Format
Output lines. If the -th sequence is a good sequence, output Yes! on the -th line; otherwise, output No!.
2
6 3 1 4 5 8 7
6 3 2 1 6 5 4
Yes!
No!
Hint
For of the testdata, .
For of the testdata, .
For of the testdata, , , .
Translated by ChatGPT 5