Logo
(追記) (追記ここまで)

17930번 - Hanging Out on the Terrace 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 (추가 시간 없음) 512 MB19015614082.353%

문제

The HiQ office in Stockholm has a pretty awesome rooftop terrace, often used in company parties and events such as programming competitions.

Unfortunately, fire safety rules limit the number of people who can be on the terrace at any one point in time -- at most $L$ people. During a party, people come and go to the terrace, but it is pretty annoying to keep track of the number of people who are currently on the terrace. Furthermore, people often enter the terrace in groups. If a group of people wish to enter the terrace, but their addition would exceed the fire safety limit, the group will instead go and play ping pong inside.

Your task is to write a program that determines, given the sizes of the groups which attempted to enter the terrace during a party and when people left the terrace, how many times a group was denied entry to the terrace.

입력

The first line of input contains the fire safety limit 1ドル \le L \le 200$ and the number of events 0ドル \le x \le 100$.

The next $x$ lines contains the events. An event starts with one of the words "enter" or "leave", depending on whether the event describes a group attempting to enter the terrace or some set of people leaving it.
This is followed by an integer 1ドル \le p \le 200$ -- the number of people entering/leaving at this time.

The number of people who leave the terrace will never exceed the number of people currently on the terrace.

출력

Output the number of groups who were not allowed to enter the terrace during the party.

제한

예제 입력 1

4 5
enter 3
enter 2
leave 1
enter 1
enter 2

예제 출력 1

2

There may be at most 4ドル$ people on the terrace at the same time. The first thing that happens is 3ドル$ people entering the terrace. Then, a group of 2ドル$ people attempt to enter. This would bring the total number up to 3ドル + 2 = 5$. Since this is larger than 4ドル,ドル this group may not enter. A single person then leaves, meaning 2ドル$ people remain on the terrace. That person then comes back, brining the total number up to three again. Finally, a pair of people try to enter the terrace, but is again denied since this would bring the total number up to 5ドル$.

Thus, a total of 2ドル$ groups were not allowed to enter the terrace.

힌트

출처

Contest > Swedish Coding Cup > HiQ Challenge 2017 A번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /