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;
typedef long long ll;
const ll asize=2e5+5;
ll n,q,s,t,d[asize],pdsum=0,ndsum=0;
int main(){
ios_base::sync_with_stdio(0),cin.tie(NULL);
cin>>n>>q>>s>>t;
ll k,pre,a,b,c;
n++;
for(int i=0;i<n;i++){
cin>>k;
if(i){
d[i]=k-pre;
if(d[i]>=0)pdsum+=d[i];
else ndsum-=d[i];
}
pre=k;
}
for(int i=0;i<q;i++){
cin>>a>>b>>c;
ll ov=d[a];
d[a]+=c;
if(ov>=0){
if(d[a]>0)pdsum+=c;
else{
pdsum-=ov;
ndsum-=(c+ov);
}
}
else{
if(d[a]<0)ndsum-=c;
else{
ndsum+=ov;
pdsum+=(c+ov);
}
}
b++;
if(b==n)goto cont;
ov=d[b];
c=-c;
d[b]+=c;
if(ov>=0){
if(d[b]>0)pdsum+=c;
else{
pdsum-=ov;
ndsum-=(c+ov);
}
}
else{
if(d[b]<0)ndsum-=c;
else{
ndsum+=ov;
pdsum+=(c+ov);
}
}
cont:
cout<<ndsum*t-pdsum*s<<"\n";
}
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... |