답안 #632986

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
632986 2022-08-21T11:13:32 Z karolb2011 Potatoes and fertilizers (LMIO19_bulves) Python 3
0 / 100
1000 ms 29588 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 i in range(n):
    if s[i]<0:
        ww-=s[i]
        s[i]=0
    elif s[i]>p:
        ww+=s[i]-p
        s[i]=p
    for j in range(p+1):
        if j<=s[i]:
            w[j]+=s[i]-j
        else:
            w[j]=min(w[j-1],w[j]+j-s[i])        
print(w[p]+ww)
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 2772 KB Output is correct
2 Correct 19 ms 3016 KB Output is correct
3 Correct 22 ms 2972 KB Output is correct
4 Correct 143 ms 5224 KB Output is correct
5 Correct 254 ms 7540 KB Output is correct
6 Correct 646 ms 16264 KB Output is correct
7 Execution timed out 1080 ms 29588 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 2772 KB Output is correct
2 Correct 19 ms 3016 KB Output is correct
3 Correct 22 ms 2972 KB Output is correct
4 Correct 143 ms 5224 KB Output is correct
5 Correct 254 ms 7540 KB Output is correct
6 Correct 646 ms 16264 KB Output is correct
7 Execution timed out 1080 ms 29588 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 2772 KB Output is correct
2 Correct 19 ms 3016 KB Output is correct
3 Correct 13 ms 2772 KB Output is correct
4 Execution timed out 1057 ms 3052 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 2772 KB Output is correct
2 Correct 19 ms 3016 KB Output is correct
3 Correct 22 ms 2972 KB Output is correct
4 Correct 13 ms 2772 KB Output is correct
5 Execution timed out 1057 ms 3052 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 2772 KB Output is correct
2 Correct 19 ms 3016 KB Output is correct
3 Correct 22 ms 2972 KB Output is correct
4 Correct 13 ms 2772 KB Output is correct
5 Execution timed out 1057 ms 3052 KB Time limit exceeded
6 Halted 0 ms 0 KB -