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")
using namespace std;
#define int long long
int n,q,s,t;
int a[200010];
int b[200010];
int l,r,x;
long long res=0;
int cal(int x){
if(x<0){
return x*s;
}
else return x*t;
}
signed main(){
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];
}
for(int i=1;i<=n;i++){
b[i]=a[i-1]-a[i];
res+=cal(b[i]);
}
while(q--){
cin>>l>>r>>x;
res -= cal(b[l]);
b[l] -= x;
res += cal(b[l]);
if (r < n) {
res -= cal(b[r + 1]);
b[r + 1] += x;
res += cal(b[r + 1]);
}
cout<<res<<endl;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |