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);
int n, q, s, t;
cin>>n>>q>>s>>t;
vector<int> vect(n+1);
for (int i=0;i<n+1;i++) cin>>vect[i];
vector<int> diffs(n+1);
for (int 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 (int qe=0;qe<q;qe++){
int l, r, x;
cin>>l>>r>>x;
for (int 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 (int 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... |