欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1249A.Yet Another Dividing into Teams
Yet Another Dividing into Teams
You are a coach of a group consisting of students. The -th student has programming skill . All students have distinct programming skills. You want to divide them into teams in such a way that:
- No two students and such that belong to the same team (i.e. skills of each pair of students in the same team have the difference strictly greater than );
- the number of teams is the minimum possible.
You have to answer independent queries.
Input
The first line of the input contains one integer () — the number of queries. Then queries follow.
The first line of the query contains one integer () — the number of students in the query. The second line of the query contains integers (, all are distinct), where is the programming skill of the -th student.
Output
For each query, print the answer on it — the minimum number of teams you can form if no two students and such that may belong to the same team (i.e. skills of each pair of students in the same team has the difference strictly greater than )
Note
In the first query of the example, there are students with the skills . There is only one restriction here: the -st and the -th students can't be in the same team (because of ). It is possible to divide them into teams: for example, students , and are in the first team and the student in the second team.
In the second query of the example, there are students with the skills . It is possible to compose just a single team containing both students.
Samples
4
4
2 10 1 20
2
3 6
5
2 3 4 99 100
1
42
2
1
2
1
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |