This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |