#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll n, q, s, t;
ll calc(ll x){
return (x < 0 ? t : -s) * abs(x);
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> q >> s >> t;
vector<ll> a(n + 2), diff(n + 2);
for (int i = 0; i <= n; i++){
cin >> a[i];
}
ll ans = 0;
for (int i = 1; i <= n; i++){
diff[i] = a[i] - a[i - 1];
ans += calc(diff[i]);
}
while(q--){
ll l, r, x;
cin >> l >> r >> x;
ans -= calc(diff[l]);
diff[l] += x;
ans += calc(diff[l]);
if (r + 1 <= n) {
ans -= calc(diff[r + 1]);
diff[r + 1] -= x;
ans += calc(diff[r + 1]);
}
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... |