Submission #635103

#TimeUsernameProblemLanguageResultExecution timeMemory
635103karolb2011Snowball (JOI21_ho_t2)Pypy 3
100 / 100
1110 ms55600 KiB
import sys input=sys.stdin.readline n,q=list(map(int,input().split())) x=list(map(int,input().split())) y=[] for i in range(n-1): y.append([x[i+1]-x[i],i]) wc=0 wm=0 ws=0 y.sort(reverse=True) u=[0 for i in range(n)] for i in range(q): z=int(input()) wc+=z wm=max(wc,wm) ws=min(wc,ws) while len(y) and wm-ws>=y[-1][0]: c,i=y.pop() if z<0: u[i+1]+=c-wm u[i]+=wm else: u[i]+=c+ws u[i+1]-=ws while len(y): c,i=y.pop() u[i]+=wm u[i+1]-=ws u[0]-=ws u[n-1]+=wm for c in u: print(c)
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...