Submission #632621

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