#include <bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(), (a).end()
using ll = long long;
const int N = 2e5 + 24;
int n, q, s, t, a[N];
ll diff[N], sum_pos, sum_neg;
void update(int i, ll x) {
if (diff[i] > 0) sum_pos -= diff[i];
else sum_neg -= -diff[i];
diff[i] += x;
if (diff[i] > 0) sum_pos += diff[i];
else sum_neg += -diff[i];
}
void solve() {
cin >> n >> q >> s >> t;
for (int i = 0; i <= n; i++) {
cin >> a[i];
if (i) diff[i] = a[i] - a[i - 1];
}
for (int i = 1; i <= n; i++) {
if (diff[i] > 0) sum_pos += diff[i];
else sum_neg += -diff[i];
}
while (q--) {
int l, r, x; cin >> l >> r >> x;
update(l, x);
if (r < n) update(r + 1, -x);
cout << sum_neg * t - sum_pos * s << '\n';
}
}
signed main() {
cin.tie(0) -> sync_with_stdio(0);
int T = 1; // cin >> T;
while (T--) {
solve();
}
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |