CF1607C.Minimum Extraction

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Yelisey has an array aa of nn integers.

If aa has length strictly greater than 11 , then Yelisei can apply an operation called minimum extraction to it:

  1. First, Yelisei finds the minimal number mm in the array. If there are several identical minima, Yelisey can choose any of them.
  2. Then the selected minimal element is removed from the array. After that, mm is subtracted from each remaining element.

Thus, after each operation, the length of the array is reduced by 11 .

For example, if a=[1,6,4,2,4]a = [1, 6, -4, -2, -4] , then the minimum element in it is a3=4a_3 = -4 , which means that after this operation the array will be equal to a=[1(4),6(4),2(4),4(4)]=[5,10,2,0]a=[1 {- (-4)}, 6 {- (-4)}, -2 {- (-4)}, -4 {- (-4)}] = [5, 10, 2, 0] .

Since Yelisey likes big numbers, he wants the numbers in the array aa to be as big as possible.

Formally speaking, he wants to make the minimum of the numbers in array aa to be maximal possible (i.e. he want to maximize a minimum). To do this, Yelisey can apply the minimum extraction operation to the array as many times as he wants (possibly, zero). Note that the operation cannot be applied to an array of length 11 .

Help him find what maximal value can the minimal element of the array have after applying several (possibly, zero) minimum extraction operations to the array.

输入格式

The first line contains an integer tt ( 1t1041 \leq t \leq 10^4 ) — the number of test cases.

The next 2t2t lines contain descriptions of the test cases.

In the description of each test case, the first line contains an integer nn ( 1n21051 \leq n \leq 2 \cdot 10^5 ) — the original length of the array aa . The second line of the description lists nn space-separated integers aia_i ( 109ai109-10^9 \leq a_i \leq 10^9 ) — elements of the array aa .

It is guaranteed that the sum of nn over all test cases does not exceed 21052 \cdot 10^5 .

输出格式

Print tt lines, each of them containing the answer to the corresponding test case. The answer to the test case is a single integer — the maximal possible minimum in aa , which can be obtained by several applications of the described operation to it.

输入输出样例

  • 输入#1

    8
    1
    10
    2
    0 0
    3
    -1 2 0
    4
    2 10 1 7
    2
    2 3
    5
    3 2 -4 -2 0
    2
    -1 1
    1
    -2

    输出#1

    10
    0
    2
    5
    2
    2
    2
    -2

说明/提示

In the first example test case, the original length of the array n=1n = 1 . Therefore minimum extraction cannot be applied to it. Thus, the array remains unchanged and the answer is a1=10a_1 = 10 .

In the second set of input data, the array will always consist only of zeros.

In the third set, the array will be changing as follows: [1,2,0][3,1][2][\color{blue}{-1}, 2, 0] \to [3, \color{blue}{1}] \to [\color{blue}{2}] . The minimum elements are highlighted with blue\color{blue}{\text{blue}} . The maximal one is 22 .

In the fourth set, the array will be modified as [2,10,1,7][1,9,6][8,5][3][2, 10, \color{blue}{1}, 7] \to [\color{blue}{1}, 9, 6] \to [8, \color{blue}{5}] \to [\color{blue}{3}] . Similarly, the maximum of the minimum elements is 55 .

首页