欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1360B.Honest Coach
Honest Coach
There are athletes in front of you. Athletes are numbered from to from left to right. You know the strength of each athlete — the athlete number has the strength .
You want to split all athletes into two teams. Each team must have at least one athlete, and each athlete must be exactly in one team.
You want the strongest athlete from the first team to differ as little as possible from the weakest athlete from the second team. Formally, you want to split the athletes into two teams and so that the value is as small as possible, where is the maximum strength of an athlete from team , and is the minimum strength of an athlete from team .
For example, if and the strength of the athletes is , then one of the possible split into teams is:
- first team: ,
- second team: .
In this case, the value will be equal to . This example illustrates one of the ways of optimal split into two teams.
Print the minimum value .
Input
The first line contains an integer () — the number of test cases in the input. Then test cases follow.
Each test case consists of two lines.
The first line contains positive integer () — number of athletes.
The second line contains positive integers (), where — is the strength of the -th athlete. Please note that values may not be distinct.
Output
For each test case print one integer — the minimum value of with the optimal split of all athletes into two teams. Each of the athletes must be a member of exactly one of the two teams.
Note
The first test case was explained in the statement. In the second test case, one of the optimal splits is , , so the answer is .
Samples
5
5
3 1 2 6 4
6
2 1 3 2 4 3
4
7 9 3 1
2
1 1000
3
100 150 200
1
0
2
999
50
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |