This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll, ll>
#define pii pair<int, int>
#define fs first
#define sc second
#define pb push_back
void solve() {
ll n,q,s,t;
cin>>n>>q>>s>>t;
ll a[n+1],d[n];
for(int i=0;i<=n;i++)cin>>a[i];
ll inc=0,dec=0;
for(int i=0;i<n;i++){
d[i]=a[i+1]-a[i];
if(d[i]>0)inc+=d[i];
else dec+=d[i];
}
while(q--){
ll l,r,x;
cin>>l>>r>>x;
if(d[l-1]>0)inc-=d[l-1];
else dec-=d[l-1];
d[l-1]+=x;
if(d[l-1]>0)inc+=d[l-1];
else dec+=d[l-1];
if(r<n){
if(d[r]>0)inc-=d[r];
else dec-=d[r];
d[r]-=x;
if(d[r]>0)inc+=d[r];
else dec+=d[r];
}
cout<<-inc*s-dec*t<<'\n';
}
}
int main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
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... |