Submission #632994

#TimeUsernameProblemLanguageResultExecution timeMemory
632994karolb2011Potatoes and fertilizers (LMIO19_bulves)Cpython 3
0 / 100
1100 ms22720 KiB
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): z=c-j if z>=0: w[j]+=z else: w[j]-=z 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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...