欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1804B.Vaccination
Vaccination
Ethan runs a vaccination station to help people combat the seasonal flu. He analyses the historical data in order to develop an optimal strategy for vaccine usage.
Consider there are patients coming to the station on a particular day. The -th patient comes at the moment . We know that each of these patients can be asked to wait for no more than time moments. That means the -th patient can get vaccine at moments .
Vaccines come in packs, each pack consists of doses. Each patient needs exactly one dose. Packs are stored in a special fridge. After a pack is taken out of the fridge and opened, it can no longer be put back. The lifetime of the vaccine outside the fridge is moments of time. Thus, if the pack was taken out of the fridge and opened at moment , its doses can be used to vaccinate patients at moments . At moment all the remaining unused doses of this pack are thrown away.
Assume that the vaccination station has enough staff to conduct an arbitrary number of operations at every moment of time. What is the minimum number of vaccine packs required to vaccinate all patients?
Input
The first line of the input contains the number of test cases (). Then follow descriptions of the test cases.
The first line of each test case contains four integers , , and (, ). They are the number of patients, the number of doses per vaccine pack, the number of moments of time the vaccine can live outside the fridge, and the number of moments of time each of the patients can wait, respectively.
The second line of each test case contains a non-decreasing sequence (). The -th element of this sequence is the moment when the -th patient comes to the vaccination station.
It is guaranteed that the sum of over all test cases won't exceed .
Output
Output one integer, the minimum number of vaccine packs required to vaccinate all patients.
Note
In the first example, the first pack can be opened at moment to vaccinate patient . The vaccine is durable enough to be used at moments and for patients and , respectively. Then the staff needs to ask patients and to wait for moment . At moment the staff opens the second vaccine pack and serves patients and . Finally, the last patient comes at moment and immediately gets the last dose of the second pack while it is still fine.
In the second example, the vaccine should be used exactly at the moment it is taken out of the fridge. Moreover, all the patients want to be served at exactly the same moment they come. That means the staff needs to open two packs at moment and use five doses on patients , , , , and . There will be three doses left ouf of these two packs but they can't be used for patient . When patient comes at moment the staff needs to open a new pack just to use only one dose out of it.
Samples
5
6 3 5 3
1 2 3 10 11 18
6 4 0 0
3 3 3 3 3 4
9 10 2 2
0 1 2 3 4 5 6 7 8
3 10 3 6
10 20 30
5 5 4 4
0 2 4 6 8
2
3
2
3
1
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |