제출 #590311

#제출 시각아이디문제언어결과실행 시간메모리
590311dnialhFoehn Phenomena (JOI17_foehn_phenomena)Pypy 3
100 / 100
317 ms54444 KiB
import sys input = sys.stdin.readline n,q,s,t = map(int, input().split()) a = [] for _ in range(n + 1) : a.append(int(input())) diff = [] res = 0 for i in range(n): diff.append(a[i+1] - a[i]) def calc(x): if x < 0: return -x * t return -x * s for v in diff: res += calc(v) out = [] for _ in range(q): l,r,x = map(int, input().split()) if l: res -= calc(diff[l - 1]) diff[l - 1] += x res += calc(diff[l - 1]) if r < n: res -= calc(diff[r]) diff[r] -= x res += calc(diff[r]) out.append(res) print('\n'.join(map(str, out)))
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...