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>
#define ll long long
using namespace std;
int n,q,s,t,i,j,l,r,v,tmp;
ll a[200010];
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin >> n >> q >> s >> t;
for(i=0;i<=n;i++) cin >> a[i];
for(j=1;j<=q;j++){
tmp=0;
cin >> l >> r >> v;
for(i=l;i<=r;i++) a[i]+=v;
for(i=0;i<n;i++){
if(a[i]<a[i+1]) tmp-=(a[i+1]-a[i])*s;
else tmp+=(a[i]-a[i+1])*t;
}
cout << tmp << "\n";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |