시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 (추가 시간 없음) | 1024 MB | 279 | 201 | 182 | 75.207% |
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.
3 3 -5 3
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번