欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1607C.Minimum Extraction
Minimum Extraction
Yelisey has an array of integers.
If has length strictly greater than , then Yelisei can apply an operation called minimum extraction to it:
- First, Yelisei finds the minimal number in the array. If there are several identical minima, Yelisey can choose any of them.
- Then the selected minimal element is removed from the array. After that, is subtracted from each remaining element.
Thus, after each operation, the length of the array is reduced by .
For example, if , then the minimum element in it is , 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]$.
Since Yelisey likes big numbers, he wants the numbers in the array to be as big as possible.
Formally speaking, he wants to make the minimum of the numbers in array 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 .
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.
Input
The first line contains an integer () — the number of test cases.
The next lines contain descriptions of the test cases.
In the description of each test case, the first line contains an integer () — the original length of the array . The second line of the description lists space-separated integers () — elements of the array .
It is guaranteed that the sum of over all test cases does not exceed .
Output
Print 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 , which can be obtained by several applications of the described operation to it.
Note
In the first example test case, the original length of the array . Therefore minimum extraction cannot be applied to it. Thus, the array remains unchanged and the answer is .
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: $[\color{blue}{-1}, 2, 0] \to [3, \color{blue}{1}] \to [\color{blue}{2}]$. The minimum elements are highlighted with . The maximal one is .
In the fourth set, the array will be modified as $[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 .
Samples
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
10
0
2
5
2
2
2
-2
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |