欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF2038J.Waiting for...
Waiting for...
Monocarp is waiting for a bus at the bus stop. Unfortunately, there are many people who want to ride a bus too.
You are given a list of events of two types:
B— a bus with free seats arrives at the stop;P— people arrive at the stop.
These events are listed in a chronological order.
When a bus arrives, the following happens. All people at the bus stop (except for Monocarp) try to enter the bus. If there are enough free seats for all of them, then they all enter the bus. Otherwise, some people remain at the bus stop (the number of people who enter the bus is equal to the number of free seats).
If there is still at least one free seat after all people (except for Monocarp) enter the bus, then Monocarp can decide to enter this bus as well (but he might choose to wait for another bus). For each bus, you have to determine if it is possible for Monocarp to take that bus.
Input
The first line contains one integer — the number of events.
Then, lines follow. The -th of them contains the description of the -th event in one of the two following formats:
B() — a bus with free seats arrives at the stop;P() — people arrive at the stop.
Additional constraint on the input: there is at least one event of type B.
Output
For each event of type B, print YES if it is possible for Monocarp to take the corresponding bus, or NO otherwise (case-insensitive).
Samples
10
P 2
P 5
B 8
P 14
B 5
B 9
B 3
P 2
B 1
B 2
YES
NO
NO
YES
NO
YES
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |