#C9377. Photographer's Arrangement Problem

    ID: 53463 Type: Default 1000ms 256MiB

Photographer's Arrangement Problem

Photographer's Arrangement Problem

In this problem, you are given a group of people with different heights. Your task is to determine if it is possible to arrange them in two rows for a photograph such that, after sorting the heights in non-decreasing order, each person in the first row is strictly shorter than the corresponding person in the second row. Formally, if after sorting the heights we split the list into two parts with the first part containing the first (\lfloor n/2 \rfloor) elements and the second part containing the remaining elements, then for every valid index (i) we require that (a_i < b_i). Note that if (n = 0) or (n = 1), the arrangement is always considered possible. This is a typical greedy problem that tests your understanding of sorting and pairing elements under constraints.

inputFormat

The first line contains an integer (T) (number of test cases). Each test case begins with an integer (n) denoting the number of people. If (n > 0), the next line contains (n) space-separated integers representing the heights of the people.

outputFormat

For each test case, output a single line containing either "YES" if it is possible to arrange the people in two rows as required, or "NO" otherwise.## sample

5
5
160 150 170 180 190
4
100 100 100 100
6
200 150 160 170 180 140
0
3
130 120 100
YES

NO YES YES YES

</p>