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<iostream>
#include<stdio.h>
using namespace std;
typedef long long int lld;
lld s,t;
lld f(lld x){
if(x>0)return s*x;
return t*x;
}
int main(){
int n,q;
cin>>n>>q>>s>>t;
lld arr[n+1];
for(int i=0;i<=n;i++){
cin>>arr[i];
}
lld diff[n];
for(int i=0;i<n;i++)diff[i]=arr[i+1]-arr[i];
lld ans=0;
for(int i=0;i<n;i++)ans+=f(diff[i]);
//cout<<ans<<endl;
while(q--){
int x,y;
cin>>x>>y;
lld change;
cin>>change;
x--;
ans-=f(diff[x]);
diff[x]+=change;
ans+=f(diff[x]);
if(y<n){
ans-=f(diff[y]);
diff[y]-=change;
ans+=f(diff[y]);
}
cout<<-ans<<endl;
/*for(int i=0;i<n;i++)cout<<f(diff[i])<<" ";
cout<<endl;*/
}
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... |