Submission #632993

# Submission time Handle Problem Language Result Execution time Memory
632993 2022-08-21T11:28:08 Z karolb2011 Potatoes and fertilizers (LMIO19_bulves) Python 3
0 / 100
1000 ms 22796 KB
import sys
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)
w=[0 for i in range(p+1)]
for c in s:
    q=False
    if c<0:
        ww-=c
        c=0
    elif c>p:
        ww+=c-p
        c=p
    for j in range(p+1):
        if j<=c:
            w[j]+=c-j
        else:
            w[j]+=j-c
            if w[j]>=w[j-1]:
                mm=w[j-1]
                q=True
                break
    if q:
        for k in range(j,p+1):
            w[k]=mm
print(w[p]+ww)
# Verdict Execution time Memory Grader output
1 Correct 12 ms 2772 KB Output is correct
2 Correct 19 ms 2904 KB Output is correct
3 Correct 19 ms 3020 KB Output is correct
4 Correct 122 ms 4916 KB Output is correct
5 Correct 228 ms 7036 KB Output is correct
6 Correct 517 ms 12856 KB Output is correct
7 Execution timed out 1073 ms 22796 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 12 ms 2772 KB Output is correct
2 Correct 19 ms 2904 KB Output is correct
3 Correct 19 ms 3020 KB Output is correct
4 Correct 122 ms 4916 KB Output is correct
5 Correct 228 ms 7036 KB Output is correct
6 Correct 517 ms 12856 KB Output is correct
7 Execution timed out 1073 ms 22796 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 12 ms 2772 KB Output is correct
2 Correct 19 ms 2904 KB Output is correct
3 Correct 13 ms 2772 KB Output is correct
4 Correct 495 ms 2960 KB Output is correct
5 Execution timed out 1065 ms 3132 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 12 ms 2772 KB Output is correct
2 Correct 19 ms 2904 KB Output is correct
3 Correct 19 ms 3020 KB Output is correct
4 Correct 13 ms 2772 KB Output is correct
5 Correct 495 ms 2960 KB Output is correct
6 Execution timed out 1065 ms 3132 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 12 ms 2772 KB Output is correct
2 Correct 19 ms 2904 KB Output is correct
3 Correct 19 ms 3020 KB Output is correct
4 Correct 13 ms 2772 KB Output is correct
5 Correct 495 ms 2960 KB Output is correct
6 Execution timed out 1065 ms 3132 KB Time limit exceeded
7 Halted 0 ms 0 KB -