#P17444. 极差数组操作 / Range Minimization
极差数组操作 / Range Minimization
Problem Description
The range spread of an array is defined as the difference between its maximum element and its minimum element.
Given an integer array of length , you may perform the following operation any number of times (including zero times):
- Choose two different indices ( and ), then update:$$a_i \leftarrow a_i + 3,\qquad a_j \leftarrow a_j - 1.$$
Compute the minimum possible range spread of array after performing some operations.
Input Format
This problem contains multiple testcases.
The first line contains an integer (), the number of testcases.
For each testcase:
- The first line contains an integer (), the length of array .
- The second line contains integers (), the elements of array .
It is guaranteed that the sum of over all testcases does not exceed .
Output Format
For each testcase, output one integer per line, the minimum range spread that can be achieved after any finite number of operations.
3
1
5
2
0 2
4
-1 9 5 8
0
2
1
Hint
In the first testcase, there is only one element, so the range spread is always .
Translated by ChatGPT 5