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

34383번 - Toll Booths 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 2048 MB35302388.462%

문제

You're getting ready to take a tour of Space School of Mines, a new branch of Colorado School of Mines, when you look at your tourist's guide and notice that you will pass through several toll booths on the flight there. You pull out your container of BlasterBucks (the local space currency) and get ready to pay up.

But, while looking at your tourist's guide, you notice something interesting. Some of the tolls are asking for payments of BlasterBucks, but some of the tolls are giving away BlasterBucks!

Your tourist's guide tells you the order of the tolls you will encounter, and how much each one is asking for or giving away (your input).

You need to make sure that whenever you reach a toll that is asking for BlasterBucks, you have enough to pay the toll. What is the minimum number of BlasterBucks that you can start with that will let you pass through all the tolls in order?

입력

The first line of input is a single number $N,ドル representing the total number of toll booths. For all inputs, 1ドル \leq N \leq 10,000円$.

The following $N$ lines of input are each of the sequential toll booths. Each toll booth is represented by a letter followed by a number, 1ドル \leq A \leq 1,000円,ドル with a space in between. The letter can be a "T" or a "G", indicating that the toll is either taking or giving BlasterBucks, respectively. The number, $A,ドル is the amount being taken or given.

출력

Your output should be a single number, indicating the minimum non-negative number of credits that you need to bring with you to pass through all of the toll booths in order.

제한

예제 입력 1

3
T 1
T 2
T 3

예제 출력 1

6

예제 입력 2

4
G 8
T 8
G 9
T 10

예제 출력 2

1

예제 입력 3

2
T 1
G 100

예제 출력 3

1

노트

출처

School > CS@Mines > CS@Mines HSPC 2022 > Beginner D번

School > CS@Mines > CS@Mines HSPC 2022 > Advanced K번

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

출처

대학교 대회

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

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