← Back to List

5612번: 터널의 입구와 출구 ↗

Solutions

Python 3
236 B | 236 chars
M=0
n=int(input())
current = int(input())
for i in range(n):
    a,b=list(map(int,input().split()))
    current +=a
    current -=b
    if current < 0:
        print(0)
        break
    else:
        M=max(M,current)
else:
    print(M)