아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Restroom Monitor

시간 제한1초메모리 제한1024 MB

요약
변기 s개와 화장지 한 롤이 있을 때, 마감 시간이 있는 n명이 모두 제때 끝낼 수 있는지 판정한다.
난이도

보통10점 중 7점

유형
그리디, 정렬, 구간, 완전 탐색
정답자
아직 제출이 없습니다

문제

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 nn 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 …\ldots can you help her?

입력

Input begins with a line containing two integers ss and nn, where 1≤s≤50,0001 \leq s \leq 50\\,000 is the number of stalls and 1≤n≤100,0001 \leq n \leq 100\\,000 is the number of people who need to use a restroom. Following this are nn lines, one for each person. Each line contains an integer dd, 1≤d≤1091 \leq d \leq 10^9 (the deadline) and a character tt.  If tt is y, then this person needs the toilet paper; if tt 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.

예제2

  1. 예제 1

    입력
    3 7
    2 y
    2 n
    5 y
    1 n
    5 n
    2 y
    1 n
    
    예상 출력
    Yes
    
  2. 예제 2

    입력
    2 7
    2 y
    2 n
    5 y
    1 n
    5 n
    2 y
    1 n
    
    예상 출력
    No