#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
const long long oo = 1e18;
int n, q, s, t, a[N], d[N];
void solve(void) {
cin >> n >> q >> s >> t;
long long ans = 0;
cin >> a[0];
for (int i = 1; i <= n; i++) {
cin >> a[i];
d[i] = a[i - 1] - a[i];
ans += 1LL * d[i] * (a[i - 1] < a[i] ? s : t);
}
auto update = [&] (int i, int x) {
ans -= 1LL * d[i] * (d[i] < 0 ? s : t);
d[i] += x;
ans += 1LL * d[i] * (d[i] < 0 ? s : t);
};
while (q--) {
int l, r, x; cin >> l >> r >> x;
update(l, -x);
if (r < n) update(r + 1, +x);
cout << ans << '\n';
}
}
signed main(void) {
ios::sync_with_stdio(false); cin.tie(nullptr);
int T = 1;// cin >> T;
while (T--) solve();
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... |