#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
int main() {
    cin.tie(0) -> sync_with_stdio(0);
    int n, q, s, t;
    cin >> n >> q >> s >> t;
    vector<ll> A(n + 1);
    for (int i = 0; i <= n; i++) {
        cin >> A[i];
    }
    vector<ll> diff(n);
    ll res = 0;
    for (int i = 0; i < n; i++) {
        diff[i] = A[i + 1] - A[i];
        if (diff[i] > 0) {
            res -= s * diff[i];
        } else {
            res += t * (-diff[i]);
        }
    }
    // cout << res << "\n";
    while (q--) {
        int L, R;
        ll k;
        cin >> L >> R >> k;
        int idx = L - 1;
        if (diff[idx] > 0)
            res += s * diff[idx];
        else
            res -= t * (-diff[idx]);
        diff[idx] += k;
        if (diff[idx] > 0)
            res -= s * diff[idx];
        else
            res += t * (-diff[idx]);
        if (R < n) {
            idx = R;
            if (diff[idx] > 0)
                res += s * diff[idx];
            else
                res -= t * (-diff[idx]);
            diff[idx] -= k;
            if (diff[idx] > 0)
                res -= s * diff[idx];
            else
                res += t * (-diff[idx]);
        }
        cout << res << "\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... |