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