#P10444. 「MYOI-R3」极差
「MYOI-R3」极差
Problem Description
For a sequence , define the range of as the difference between the maximum value and the minimum value in . Now you are given a sequence of length . Determine whether it is possible to split it into at least two subsequences, each of length greater than , such that the range of every subsequence is equal (note that all elements must be assigned, and each element can be assigned to only one subsequence).
Input Format
This problem contains multiple test cases.
The first line contains two integers , representing the number of test cases and the subtask ID.
For each test case:
The first line contains a positive integer , representing the length of the array.
The second line contains integers representing the sequence .
Output Format
For each test case, output one line containing a string Yes or No.
2 1
6
1 1 4 5 1 4
7
1 9 1 9 8 1 0
No
Yes
Hint
Explanation for Sample
The sample satisfies the constraints of Subtask 1, with .
Query 1:
It can be proven that no solution satisfies the conditions.
Query 2:
One valid set of subsequences is:
- .
- .
- .
The answer is not unique.
Constraints
This problem uses bundled testdata.
- Subtask 1 (20 points): .
- Subtask 2 (20 points): .
- Subtask 3 (20 points): .
- Subtask 4 (10 points): all elements in array are equal.
- Subtask 5 (30 points): no special restrictions.
For of the testdata, $4\le \sum n\le 10^6,0\le |a_i|\le 10^9,1\le T\le 300$.
Translated by ChatGPT 5