#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll calc(ll diff, ll s, ll t){
if(diff>0) return -diff*s;
else return -diff*t;
}
int main(){
cin.tie(0)->sync_with_stdio(0);
ll n, q, s, t, l, r, x, temp = 0;
cin>>n>>q>>s>>t;
ll a[n+1], d[n+1];
a[0] = 0;
for(int i=0;i<=n;i++){
cin>>a[i];
if(i!=0){
d[i] = a[i] - a[i-1];
temp += calc(d[i], s, t);
}
}
for(int i=0;i<q;i++){
cin>>l>>r>>x;
temp -= calc(d[l], s, t);
d[l] += x;
temp += calc(d[l], s, t);
if(r+1<=n){
temp -= calc(d[r+1], s, t);
d[r+1] -= x;
temp += calc(d[r+1], s, t);
}
cout<<temp<<"\n";
}
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |