#C5503. Splitting Decreasing Subarrays
Splitting Decreasing Subarrays
Splitting Decreasing Subarrays
Given a sequence of integers, your task is to determine whether it is possible to split the sequence into several contiguous strictly decreasing subarrays, where each subarray has a length of at least 2, such that the total length of these subarrays is at least half of the length of the original sequence.
Formally, let \( m \) be the length of the sequence. You need to partition the sequence into maximal contiguous segments that are strictly decreasing. Only those segments with length \( \ge 2 \) are considered, and let \( D \) be the sum of their lengths. The answer is "YES" if \( D \ge \frac{m}{2} \); otherwise, the answer is "NO".
You will be given \( q \) test cases. For each test case:
- The first number is \( m \), the number of elements in the sequence.
- The next \( m \) numbers form the sequence.
Output one line per test case containing either "YES" or "NO".
inputFormat
The input is read from stdin and is in the following format:
q m1 a1 a2 ... am1 m2 b1 b2 ... bm2 ... mq c1 c2 ... cmq
Here, \( q \) is the number of test cases; each test case starts with an integer \( m \) (the length of the sequence) followed by \( m \) space-separated integers.
outputFormat
For each test case, print a single line to stdout containing either "YES" or "NO" depending on whether the sequence meets the criteria.
## sample3
6 10 3 8 5 7 2
5 1 2 3 4 5
4 9 8 7 6
YES
NO
YES
</p>