QOJ.ac

QOJ

حد الوقت: 1 s حد الذاكرة: 1024 MB مجموع النقاط: 100

#3619. 洗手间管理员

الإحصائيات

Irma P. Freely 负责 Rest Pit 卡车站的洗手间管理工作。每隔一段时间,就会有一辆旅游巴士停靠,一群乘客下车使用洗手间。Irma 有 $n$ 个单间洗手间可以分配给这些人。每个人使用设施所需的时间相同,但他们必须完成使用的“截止时间”可能不同。由于 Irma 工作出色,她可以观察排队的人并准确估计出他们的截止时间。

不幸的是,由于新冠疫情导致的物资短缺,现在只有一卷卫生纸。并非每个人都需要卫生纸,但同一时间只能有一个人使用带有卫生纸的隔间。Irma 需要确定她是否能安排好每个人,使他们都能在截止时间前使用完设施。这听起来有很多文书工作……你能帮帮她吗?

输入格式

输入的第一行包含两个整数 $s$ 和 $n$,其中 $1 \le s \le 50\,000$ 是洗手间的数量,$1 \le n \le 100\,000$ 是需要使用洗手间的人数。接下来有 $n$ 行,每行对应一个人。每行包含一个整数 $d$ ($1 \le d \le 10^9$,即截止时间) 和一个字符 $t$。如果 $t$ 为 $y$,则表示此人需要卫生纸;如果 $t$ 为 $n$,则表示不需要。假设每位用户需要一个单位的时间,且截止时间也以相同的单位指定。

输出格式

如果可以将每个人分配到洗手间并满足他们的截止时间,输出 Yes。否则,输出 No

样例

样例输入 1

3 7
2 y
2 n
5 y
1 n
5 n
2 y
1 n

样例输出 1

Yes

样例输入 2

2 7
2 y
2 n
5 y
1 n
5 n
2 y
1 n

样例输出 2

No

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.