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 <vector>
using namespace std;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long n, q, s, t;
cin>>n>>q>>s>>t;
vector<long long> vect(n+1);
for (long long i=0;i<n+1;i++) cin>>vect[i];
vector<long long> diffs(n+1);
for (long long i=1;i<n+1;i++){
diffs[i]=diffs[i-1];
if (vect[i]>vect[i-1]) diffs[i]-=s*(vect[i]-vect[i-1]);
else diffs[i]+=t*(vect[i-1]-vect[i]);
}
for (long long qe=0;qe<q;qe++){
long long l, r, x;
cin>>l>>r>>x;
for (long long i=l;i<=r;i++){
vect[i]+=x;
diffs[i]=diffs[i-1];
if (vect[i]>vect[i-1]) diffs[i]-=s*(vect[i]-vect[i-1]);
else diffs[i]+=t*(vect[i-1]-vect[i]);
}
for (long long i=r+1;i<n+1;i++){
diffs[i]=diffs[i-1];
if (vect[i]>vect[i-1]) diffs[i]-=s*(vect[i]-vect[i-1]);
else diffs[i]+=t*(vect[i-1]-vect[i]);
}
cout<<diffs[n]<<'\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... |