답안 #633087

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
633087 2022-08-21T15:14:35 Z karolb2011 Potatoes and fertilizers (LMIO19_bulves) Python 3
0 / 100
13 ms 2900 KB
import sys
import heapq as hq
input = sys.stdin.readline
n=int(input())
p=0
s=[]
z=0
for i in range(n):
    a,b=list(map(int,input().split()))
    p+=b-a
    s.append(p)
w=[]
for c in s:
    if c>0:
        z+=c
        c=0
    elif c<p:
        ww-=c-p
        c=p
    hq.heappush(w,c)
    if w[0]<c:
        hq.heappush(w,c)
        z+=abs(hq.heappop(w)-c)
print(z)
# 결과 실행 시간 메모리 Grader output
1 Runtime error 13 ms 2900 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 13 ms 2900 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 13 ms 2900 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 13 ms 2900 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 13 ms 2900 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -