Submission #632611

#TimeUsernameProblemLanguageResultExecution timeMemory
632611karolb2011Potatoes and fertilizers (LMIO19_bulves)Cpython 3
0 / 100
1012 ms65292 KiB
import sys input = sys.stdin.readline n=int(input()) w=0 t=0 p=0 s=[] r=[] for i in range(n): pi,bi=list(map(int,input().split())) p+=pi-bi w+=abs(p) t+=abs(p-1) s.append(w) r.append(t) if p>0: for i in range(n): w=min(w,s[i]-r[i]+t) print(w)
#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...