#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define int long long
const int MX = 1e5 + 5;
const int MOD = 1e9 + 7;
int n, q, s, t;
int a[MX], p[MX];
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
// int test; cin>>test; while (test--) {}
cin >> n >> q >> s >> t;
for (int i = 0; i <= n; i++) cin >> a[i];
int fn = 0;
auto get = [&] (int x) {
if (x < 0) return -t;
else return -s;
};
for (int i = 1; i <= n; i++) {
p[i] = a[i] - a[i - 1];
fn += p[i] * get(p[i]);
}
// cout << fn << '\n';
while (q--) {
int l, r, x; cin >> l >> r >> x;
fn -= p[l] * get(p[l]);
p[l] += x;
fn += p[l] * get(p[l]);
if (r < n) {
fn -= p[r + 1] * get(p[r + 1]);
p[r + 1] -= x;
fn += p[r + 1] * get(p[r + 1]);
}
cout << fn << '\n';
}
return 0;
}
// binhtinhtutinkhongcaycunhungmotkhikhongcontutinnualatuyetvong
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |