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

34433번 - Mountain Bike Trail 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
8 초 2048 MB1912969.231%

문제

When riding on a singletrack mountain bike trail, the courtesy is for riders going downhill to yield to riders going uphill. Often, the uphill riders will let the downhill rider know about how many riders are behind them in their group so the downhill rider knows what to watch for. For example, if there are five riders in a group, the first one may say "4 back", the second may say "3 back", repeating this pattern until the last rider says "just me."

You have been volunteering for the local mountain bike trail maintenance club and have been put in charge of collecting statistics on the number of groups riding up your favorite trail. To do so, you decided the most fun way would be to ride down the trail and use a tape recorder to record what everyone says as you let them by, and use a computer program to do the counting.

Due to the fact that some riders fall really far behind from their group, the groups may not be in order. Additionally, some members of the group may have gotten really tired and decided to wait at the bottom of the trail, so not every group will end with "just me."

입력

The first line of input contains a single integer $N$ (0ドル \le N \le 10^6$), indicating the number of riders you passed as you biked down the trail.

The next $N$ lines contain either:

  • The text "just me", indicating the rider was the last rider in a group.
  • Or, an integer $m$ (1ドル \le m < 10^6$), indicating the number of riders in the same group who are behind the uphill rider, followed by the string "back".

You may assume that all riders are completely knowledgeable of the current number of riders behind themselves in their group, and will always correctly answer the number of riders in their group behind themselves. Likewise, riders will never disappear on the trail. If a rider says "4 back" then the next rider in their group (if one is on the trail) will not say anything but "3 back".

출력

Output two integers on the same line, separated by a space. The first integer represents the minimum number of groups you may have seen on the trail, and the second integer represents the maximum number of groups you may have seen on the trail.

제한

예제 입력 1

5
4 back
3 back
2 back
1 back
just me

예제 출력 1

1 5

예제 입력 2

12
2 back
4 back
3 back
2 back
4 back
3 back
2 back
1 back
1 back
1 back
just me
just me

예제 출력 2

3 12

노트

출처

School > CS@Mines > CS@Mines HSPC 2020 J번

  • 문제를 만든 사람: Jack Rosenthal
(追記) (追記ここまで)

출처

대학교 대회

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

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