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>
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#define int long long
using namespace std;
const int N=2e5+50;
int n,q,s,t,ans=0,l,r,k;
int a[N],dif[N];
int provjp(int x){
if(x>0) return -s*x;
else return -t*x;
}
signed main(){
// freopen(".inp","r",stdin);
// freopen(".out","w",stdout);
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin>>n>>q>>s>>t;
for(int i=0;i<=n;i++){
cin>>a[i];
dif[i]=a[i]-a[i-1];
if(i>0) ans+=provjp(dif[i]);
}
while(q--){
cin>>l>>r>>k;
ans-=provjp(dif[l]);
dif[l]+=k;
ans+=provjp(dif[l]);
if(r<n){
ans-=provjp(dif[r+1]);
dif[r+1]-=k;
ans+=provjp(dif[r+1]);
}
cout<<ans<<"\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... |