#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define MAXN 500005
ll a[MAXN], ans, p, D[MAXN];
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N, Q;
ll S, T;
cin >> N >> Q >> S >> T;
for(int i = 0; i <= N; i++) {
cin >> a[i];
}
for(int i = 1; i <= N; i++) {
D[i] = a[i] - a[i - 1];
if(D[i] > 0) ans -= S * D[i];
else ans += T * (-D[i]);
}
for(int i = 1; i <= Q; i++) {
int l, r, vl;
cin >> l >> r >> vl;
if(D[l] > 0) ans += S * D[l];
else ans -= T * (-D[l]);
D[l] += vl;
if(D[l] > 0) ans -= S * D[l];
else ans += T * (-D[l]);
if(r + 1 <= N) {
r++;
if(D[r] > 0) ans += S * D[r];
else ans -= T * (-D[r]);
D[r] -= vl;
if(D[r] > 0) ans -= S * D[r];
else ans += T * (-D[r]);
}
cout << ans << '\n';
}
return 0;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |