Restroommonitor
题号:NC226987
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 1024 M,其他语言2048 M
64bit IO Format: %lld

题目描述

Irma P. Freely (yes, we've hit a new low) is in charge of the bank of restrooms at the Rest Pit truck stop. Every so often a tour bus stops by and a load of passengers gets off to use the restroom. Irma has a set of  single-stall restrooms she can allocate to people. Everyone takes the same amount of time to use the facilities but may have different "deadlines" for when they must be finished. Being good at her job, Irma can look at the people in line and estimate with complete accuracy what their deadlines are.

Unfortunately, owing to shortages caused by the COVID pandemic, there is only one roll of toilet paper. Not everyone needs toilet paper, but only one person can be in a stall with it at a time. Irma needs to figure out whether she can schedule everyone so that they can all make use of her facilities before their deadlines. Sounds like a lot of paperwork  can you help her?

输入描述:

Input begins with a line containing two integers  and , where  is the number of stalls and  is the number of people who need to use a restroom. Following this are  lines, one for each person. Each line contains an integer  (the deadline) and a character . If  is y, then this person needs the toilet paper; if  is n, they don't. Assume each user requires one unit of time and that deadlines are specified in terms of the same unit.

输出描述:

If it is possible to allocate everyone to stalls to meet their deadlines, display Yes. Otherwise, display No.
示例1

输入

复制
3 7
2 y
2 n
5 y
1 n
5 n
2 y
1 n

输出

复制
Yes
示例2

输入

复制
2 7
2 y
2 n
5 y
1 n
5 n
2 y
1 n

输出

复制
No