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>
#define ll long long
#define fi first
#define sec second
#define pb push_back
#define pqueue priority_queue
#define int long long
#define pii pair<int,int>
#define supercepat ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
using namespace std;
int tc,ans=0,n,q,s,t,l,r,x;
int a[200005];
int diff[200005];
int sump,summ;
main(){
supercepat;
cin>>n>>q>>s>>t;
for(int i=0;i<=n;i++) cin>>a[i];
for(int i=1;i<=n;i++){
diff[i]=a[i]-a[i-1];
if(diff[i]>0) summ+=diff[i];
else sump+=abs(diff[i]);
}
while(q--){
cin>>l>>r>>x;
if(diff[l]>0) summ-=diff[l];
else sump-=abs(diff[l]);
diff[l]+=x;
if(diff[l]>0) summ+=diff[l];
else sump+=abs(diff[l]);
if(r<n){
if(diff[r+1]>0) summ-=diff[r+1];
else sump-=abs(diff[r+1]);
diff[r+1]-=x;
if(diff[r+1]>0) summ+=diff[r+1];
else sump+=abs(diff[r+1]);
}
ans=sump*t-(summ*s);
cout<<ans<<endl;
}
}
Compilation message (stderr)
foehn_phenomena.cpp:15:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
15 | main(){
| ^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |