欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
SIMD12A.急诊分诊
急诊分诊
Statement
A hospital has doctors, all initially idle. The system receives commands in nondecreasing time order. Each patient has a unique identifier, a priority, and a treatment duration. Larger priority is served first; ties are broken by earlier arrival time and then by smaller identifier.
Before processing a command at time , all treatments ending no later than are processed. When a doctor finishes at time , the doctor immediately starts treating the best patient currently waiting, if one exists. Then the current command is executed. Whenever both an idle doctor and a waiting patient exist, treatment starts immediately.
Commands are A t id p d (arrival), C t id (cancel only if still waiting), and Q t (print the number waiting, number under treatment, and the identifier at the head of the waiting queue, or 0 if it is empty).
Input
The first line contains (). The next lines contain commands in nondecreasing time order. Arrival identifiers are distinct and lie in . All priorities and durations are positive.
Output
For every query, print the waiting count, treating count, and current waiting-queue head identifier.
Samples
Sample 1
Input:
1 8
A 0 1 5 4
A 1 2 9 3
Q 1
C 2 2
Q 2
A 4 3 7 2
Q 4
Q 6
Output:
1 1 2
0 1 0
0 1 0
0 0 0
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |