본문 바로가기
Beakjoon&프로그래머스/파이썬

[백준/파이썬] 24609번 Overdraft

by 현장 2023. 3. 24.

-Code

n = int(input())

st = 0
res = 0
for _ in range(n):
    num = int(input())

    if st + num < 0:
        res += abs(st + num)
        st = 0
        continue

    st += num

print(res)