Submission #632623

#TimeUsernameProblemLanguageResultExecution timeMemory
632623karolb2011Potatoes and fertilizers (LMIO19_bulves)Cpython 3
34 / 100
916 ms26928 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: w=min(w,t,min(s)+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...