#4609. [UOI 2025] Convex Array
[UOI 2025] Convex Array
[UOI 2025] Convex Array
题目描述
You are given an array of integers $a$ of length $n$.Determine whether there exists a permutation of its elements such that for every , the condition holds.
In this problem, each test contains several sets of input data. You need to solve the problem independently for each such set.
输入格式
The first line contains a single integer $T$ $(1\le T\le 10^5)$ --- the number of sets of input data. The description of the input data sets follows.In the first line of each input data set, there is a single integer --- the length of the array .
In the second line of each input data set, there are integers --- the elements of the array .
It is guaranteed that the sum of across all input data sets of a single test does not exceed .
输出格式
For each set of input data, output on a separate line $\tt{YES}$, if the desired permutation exists, and $\tt{NO}$ otherwise.10
4
0 3 4 6
4
5 4 1 4
8
1 4 4 8 6 10 10 4
7
2 1 5 1 9 4 6
6
7 1 6 10 2 3
7
6 6 10 2 5 3 8
4
9 9 1 5
4
8 4 3 4
7
1 2 1 6 4 2 9
7
3 9 7 5 9 10 10
YES
NO
NO
YES
YES
NO
YES
YES
YES
NO
提示
In the first set of input data from the first example, the permutations of the array $[0, 3, 4, 6]$ that satisfy the described condition are $[4, 0, 3, 6]$ and $[6, 3, 0, 4]$.Scoring
Let be the sum over all input data sets of one test.
- ( points): ;
- ( points): , ;
- ( points): , ;
- ( points): if some desired permutation exists, then there exists such a desired permutation for which and ;
- ( points): ;
- ( points): ;
- ( points): ;
- ( points): ;
- ( points): for ;
- ( points): without additional restrictions. 标签: P12546|动态规划 DP|2025|动态规划优化|分类讨论|UOI(乌克兰)