Submission #633062

# Submission time Handle Problem Language Result Execution time Memory
633062 2022-08-21T14:06:01 Z karolb2011 Potatoes and fertilizers (LMIO19_bulves) Python 3
54 / 100
1000 ms 32388 KB
import sys
import heapq as hq
input = sys.stdin.readline
n=int(input())
t=0
p=0
s=[]
ww=0
for i in range(n):
    pi,bi=list(map(int,input().split()))
    p+=pi-bi
    s.append(p)
if p==0:
    for c in s:
        ww+=abs(c)
else:
    w=[]
    for c in s:
        if c<0:
            ww-=c
            c=0
        elif c>p:
            ww+=c-p
            c=p
        hq.heappush(w,-c)
        hq.heappush(w,-c)
        ww+=abs(-hq.heappop(w)-c)
print(ww)
# Verdict Execution time Memory Grader output
1 Correct 16 ms 2900 KB Output is correct
2 Correct 18 ms 2868 KB Output is correct
3 Correct 20 ms 2960 KB Output is correct
4 Correct 89 ms 4872 KB Output is correct
5 Correct 169 ms 6884 KB Output is correct
6 Correct 395 ms 12884 KB Output is correct
7 Correct 791 ms 22784 KB Output is correct
8 Correct 781 ms 31652 KB Output is correct
9 Correct 790 ms 27236 KB Output is correct
10 Correct 736 ms 15628 KB Output is correct
11 Correct 738 ms 18280 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 2900 KB Output is correct
2 Correct 18 ms 2868 KB Output is correct
3 Correct 20 ms 2960 KB Output is correct
4 Correct 89 ms 4872 KB Output is correct
5 Correct 169 ms 6884 KB Output is correct
6 Correct 395 ms 12884 KB Output is correct
7 Correct 791 ms 22784 KB Output is correct
8 Correct 781 ms 31652 KB Output is correct
9 Correct 790 ms 27236 KB Output is correct
10 Correct 736 ms 15628 KB Output is correct
11 Correct 738 ms 18280 KB Output is correct
12 Correct 373 ms 10620 KB Output is correct
13 Correct 808 ms 21356 KB Output is correct
14 Execution timed out 1091 ms 32388 KB Time limit exceeded
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 16 ms 2900 KB Output is correct
2 Correct 18 ms 2868 KB Output is correct
3 Correct 12 ms 2864 KB Output is correct
4 Correct 18 ms 2916 KB Output is correct
5 Correct 18 ms 2968 KB Output is correct
6 Correct 21 ms 3156 KB Output is correct
7 Correct 24 ms 3028 KB Output is correct
8 Correct 21 ms 3076 KB Output is correct
9 Correct 22 ms 3140 KB Output is correct
10 Correct 19 ms 2900 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 2900 KB Output is correct
2 Correct 18 ms 2868 KB Output is correct
3 Correct 20 ms 2960 KB Output is correct
4 Correct 12 ms 2864 KB Output is correct
5 Correct 18 ms 2916 KB Output is correct
6 Correct 18 ms 2968 KB Output is correct
7 Correct 21 ms 3156 KB Output is correct
8 Correct 24 ms 3028 KB Output is correct
9 Correct 21 ms 3076 KB Output is correct
10 Correct 22 ms 3140 KB Output is correct
11 Correct 19 ms 2900 KB Output is correct
12 Correct 19 ms 3028 KB Output is correct
13 Correct 24 ms 3108 KB Output is correct
14 Correct 21 ms 3124 KB Output is correct
15 Correct 21 ms 3116 KB Output is correct
16 Correct 21 ms 3172 KB Output is correct
17 Correct 20 ms 3132 KB Output is correct
18 Correct 20 ms 3044 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 2900 KB Output is correct
2 Correct 18 ms 2868 KB Output is correct
3 Correct 20 ms 2960 KB Output is correct
4 Correct 12 ms 2864 KB Output is correct
5 Correct 18 ms 2916 KB Output is correct
6 Correct 18 ms 2968 KB Output is correct
7 Correct 21 ms 3156 KB Output is correct
8 Correct 24 ms 3028 KB Output is correct
9 Correct 21 ms 3076 KB Output is correct
10 Correct 22 ms 3140 KB Output is correct
11 Correct 89 ms 4872 KB Output is correct
12 Correct 169 ms 6884 KB Output is correct
13 Correct 395 ms 12884 KB Output is correct
14 Correct 791 ms 22784 KB Output is correct
15 Correct 781 ms 31652 KB Output is correct
16 Correct 790 ms 27236 KB Output is correct
17 Correct 736 ms 15628 KB Output is correct
18 Correct 738 ms 18280 KB Output is correct
19 Correct 373 ms 10620 KB Output is correct
20 Correct 808 ms 21356 KB Output is correct
21 Execution timed out 1091 ms 32388 KB Time limit exceeded
22 Halted 0 ms 0 KB -