#P10444. 「MYOI-R3」极差

    ID: 11440 远端评测题 1000ms 512MiB 尝试: 2 已通过: 2 难度: 5 上传者: 标签>贪心二分洛谷原创O2优化洛谷月赛双指针 two-pointerAd-hoc

「MYOI-R3」极差

Problem Description

For a sequence cc, define the range of cc as the difference between the maximum value and the minimum value in cc. Now you are given a sequence aa of length nn. Determine whether it is possible to split it into at least two subsequences, each of length greater than 11, 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 T,idT,id, representing the number of test cases and the subtask ID.

For each test case:

The first line contains a positive integer nn, representing the length of the array.

The second line contains nn integers representing the sequence aa.

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 1\small\text{1}

The sample satisfies the constraints of Subtask 1, with id=1id=1.

Query 1:

It can be proven that no solution satisfies the conditions.

Query 2:

One valid set of subsequences is:

  • {1,9}\{1,9\}.
  • {1,9}\{1,9\}.
  • {8,1,0}\{8,1,0\}.

The answer is not unique.

Constraints

This problem uses bundled testdata.

  • Subtask 1 (20 points): 4n20,ai04\le \sum n\le 20,a_i\ge 0.
  • Subtask 2 (20 points): 4n100,ai04\le \sum n\le 100,a_i\ge 0.
  • Subtask 3 (20 points): 4n103,ai04\le \sum n\le 10^3,a_i\ge 0.
  • Subtask 4 (10 points): all elements in array aa are equal.
  • Subtask 5 (30 points): no special restrictions.

For 100%100\% 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