#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
using namespace std;
using ll = long long;
using ii = pair<int,int>;
using aa = array<int,3>;
int a[200005];
int F[200005];
void update(int pos,int val) {
  for(int i=pos;i<=200000;i+=i & -i) {
    F[i]+=val;
  }
}
int get(int pos) {
  int res=0;
  for(int i=pos;i>0;i-=i & -i) {
    res+=F[i];
  }
  return res;
}
signed main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int n,q,s,t;
    cin >> n >> q >> s >> t;
    int ans=0;
    for(int i=0;i<=n;i++) {
      cin >> a[i];
      if(i>=1) {
        if(a[i-1]<a[i]) {
          ans-=(a[i]-a[i-1])*s;
        }
        else {
          ans+=(a[i-1]-a[i])*t;
        }
      }
    }
    //cout << ans << endl;
    while(q--) {
      int l,r,x;
      cin >> l >> r >> x;
      if(a[l-1]+get(l-1)<a[l]+get(l)) {
        ans+=(a[l]+get(l)-a[l-1]-get(l-1))*s;
      }
      else {
        ans+=(a[l]+get(l)-a[l-1]-get(l-1))*t;
      }
      //cout << ans << endl;
      if(r!=n) {
        if(a[r]+get(r)<a[r+1]+get(r+1)) {
        ans+=(a[r+1]+get(r+1)-a[r]-get(r))*s;
        }
        else {
          ans+=(a[r+1]+get(r+1)-a[r]-get(r))*t;
        }
      }
      update(l,x);
      update(r+1,-x); 
      if(a[l-1]+get(l-1)<a[l]+get(l)) {
        ans-=(a[l]+get(l)-a[l-1]-get(l-1))*s;
      }
      else {
        ans-=(a[l]+get(l)-a[l-1]-get(l-1))*t;
      }
      //cout << ans << endl;
      if(r!=n) {
        if(a[r]+get(r)<a[r+1]+get(r+1)) {
          ans-=(a[r+1]+get(r+1)-a[r]-get(r))*s;
        }
        else {
          ans-=(a[r+1]+get(r+1)-a[r]-get(r))*t;
        }
      }
      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... |