답안 #633089

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
633089 2022-08-21T15:16:35 Z karolb2011 Potatoes and fertilizers (LMIO19_bulves) PyPy 3
100 / 100
604 ms 46072 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:
        z-=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 Correct 35 ms 18128 KB Output is correct
2 Correct 56 ms 20312 KB Output is correct
3 Correct 57 ms 20340 KB Output is correct
4 Correct 91 ms 27096 KB Output is correct
5 Correct 100 ms 26208 KB Output is correct
6 Correct 170 ms 31920 KB Output is correct
7 Correct 286 ms 38836 KB Output is correct
8 Correct 256 ms 40964 KB Output is correct
9 Correct 266 ms 37128 KB Output is correct
10 Correct 239 ms 36440 KB Output is correct
11 Correct 250 ms 36520 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 35 ms 18128 KB Output is correct
2 Correct 56 ms 20312 KB Output is correct
3 Correct 57 ms 20340 KB Output is correct
4 Correct 91 ms 27096 KB Output is correct
5 Correct 100 ms 26208 KB Output is correct
6 Correct 170 ms 31920 KB Output is correct
7 Correct 286 ms 38836 KB Output is correct
8 Correct 256 ms 40964 KB Output is correct
9 Correct 266 ms 37128 KB Output is correct
10 Correct 239 ms 36440 KB Output is correct
11 Correct 250 ms 36520 KB Output is correct
12 Correct 149 ms 28812 KB Output is correct
13 Correct 237 ms 35304 KB Output is correct
14 Correct 360 ms 42488 KB Output is correct
15 Correct 263 ms 41028 KB Output is correct
16 Correct 331 ms 41092 KB Output is correct
17 Correct 323 ms 40220 KB Output is correct
18 Correct 89 ms 23208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 35 ms 18128 KB Output is correct
2 Correct 56 ms 20312 KB Output is correct
3 Correct 89 ms 23208 KB Output is correct
4 Correct 36 ms 18132 KB Output is correct
5 Correct 70 ms 20384 KB Output is correct
6 Correct 112 ms 22176 KB Output is correct
7 Correct 89 ms 22916 KB Output is correct
8 Correct 78 ms 21776 KB Output is correct
9 Correct 121 ms 24648 KB Output is correct
10 Correct 60 ms 20316 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 35 ms 18128 KB Output is correct
2 Correct 56 ms 20312 KB Output is correct
3 Correct 57 ms 20340 KB Output is correct
4 Correct 36 ms 18132 KB Output is correct
5 Correct 70 ms 20384 KB Output is correct
6 Correct 112 ms 22176 KB Output is correct
7 Correct 89 ms 22916 KB Output is correct
8 Correct 78 ms 21776 KB Output is correct
9 Correct 121 ms 24648 KB Output is correct
10 Correct 60 ms 20316 KB Output is correct
11 Correct 89 ms 23208 KB Output is correct
12 Correct 115 ms 22664 KB Output is correct
13 Correct 121 ms 25372 KB Output is correct
14 Correct 127 ms 24340 KB Output is correct
15 Correct 109 ms 25420 KB Output is correct
16 Correct 85 ms 21512 KB Output is correct
17 Correct 98 ms 23084 KB Output is correct
18 Correct 89 ms 22512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 35 ms 18128 KB Output is correct
2 Correct 56 ms 20312 KB Output is correct
3 Correct 57 ms 20340 KB Output is correct
4 Correct 36 ms 18132 KB Output is correct
5 Correct 70 ms 20384 KB Output is correct
6 Correct 112 ms 22176 KB Output is correct
7 Correct 89 ms 22916 KB Output is correct
8 Correct 78 ms 21776 KB Output is correct
9 Correct 121 ms 24648 KB Output is correct
10 Correct 60 ms 20316 KB Output is correct
11 Correct 91 ms 27096 KB Output is correct
12 Correct 100 ms 26208 KB Output is correct
13 Correct 170 ms 31920 KB Output is correct
14 Correct 286 ms 38836 KB Output is correct
15 Correct 256 ms 40964 KB Output is correct
16 Correct 266 ms 37128 KB Output is correct
17 Correct 239 ms 36440 KB Output is correct
18 Correct 250 ms 36520 KB Output is correct
19 Correct 149 ms 28812 KB Output is correct
20 Correct 237 ms 35304 KB Output is correct
21 Correct 360 ms 42488 KB Output is correct
22 Correct 263 ms 41028 KB Output is correct
23 Correct 331 ms 41092 KB Output is correct
24 Correct 323 ms 40220 KB Output is correct
25 Correct 115 ms 22664 KB Output is correct
26 Correct 121 ms 25372 KB Output is correct
27 Correct 127 ms 24340 KB Output is correct
28 Correct 109 ms 25420 KB Output is correct
29 Correct 85 ms 21512 KB Output is correct
30 Correct 98 ms 23084 KB Output is correct
31 Correct 89 ms 22512 KB Output is correct
32 Correct 89 ms 23208 KB Output is correct
33 Correct 250 ms 30988 KB Output is correct
34 Correct 388 ms 36264 KB Output is correct
35 Correct 585 ms 46072 KB Output is correct
36 Correct 562 ms 45264 KB Output is correct
37 Correct 347 ms 37884 KB Output is correct
38 Correct 604 ms 45180 KB Output is correct
39 Correct 412 ms 44564 KB Output is correct
40 Correct 410 ms 40464 KB Output is correct
41 Correct 386 ms 39420 KB Output is correct
42 Correct 392 ms 41260 KB Output is correct
43 Correct 405 ms 40624 KB Output is correct
44 Correct 429 ms 39924 KB Output is correct
45 Correct 469 ms 42356 KB Output is correct
46 Correct 310 ms 40384 KB Output is correct
47 Correct 502 ms 40972 KB Output is correct