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

24609번 - Overdraft 다국어

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

문제

Banks often charge overdraft fees if you attempt to withdraw more money from your account than is available in your current balance. Given a sequence of deposits and withdrawals (and assuming each deposit and withdrawal is immediately reflected in your balance), determine the minimum (non-negative) starting balance you need to ensure that you will not be charged any overdraft fees over the course of the sequence.

입력

The first line of input contains a single integer $n$ (1ドル \le n \le 1{,}000$), which is the number of transactions.

Each of the next $n$ lines contains a single integer $t$ ($-10^6 \le t \le 10^6,ドル $t \neq 0$). These are the transactions, in the order that they occur. A positive number represents a deposit, a negative number represents a withdrawal. No two transactions occur simultaneously.

출력

Output a single non-negative integer, which is the minimum non-negative balance you must start with in your account in order to avoid any overdraft fees.

제한

예제 입력 1

3
3
-5
3

예제 출력 1

2

힌트

출처

ICPC > Regionals > North America > South Central USA Regional > 2021 South Central USA Regional Contest > Division 2 F번

ICPC > Regionals > North America > Mid-Central Regional > Mid-Central USA Programming Contest 2021 E번

ICPC > Regionals > North America > Southeast USA Regional > 2021 Southeast USA Regional Programming Contest > Division 2 F번

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

출처

대학교 대회

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

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