luogu#P1410. 子序列

子序列

Problem Description

Given a sequence of length NN (where NN is even), determine whether it can be partitioned into two strictly increasing subsequences, each of length N/2N / 2.

Input Format

Multiple lines, each line represents one set of testdata.

For each set of testdata, first input an integer NN, the length of the sequence. Then NN integers follow, representing the sequence.

Output Format

The number of output lines is the same as the number of input lines.

For each set of testdata, if such a partition exists, output Yes!, otherwise output No!.

6 3 1 4 5 8 7
6 3 2 1 6 5 4

Yes!
No!

Hint

Constraints

There are three sets of testdata, each set contains at most 5050 lines, 00 \le all input numbers 109\le 10^9.

Set 1 (30%30\%): N20N \le 20;

Set 2 (30%30\%): N100N \le 100;

Set 3 (40%40\%): N2000N \le 2000.

Translated by ChatGPT 5