Submission #632622

#TimeUsernameProblemLanguageResultExecution timeMemory
632622karolb2011Potatoes and fertilizers (LMIO19_bulves)Cpython 3
24 / 100
925 ms27608 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,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...