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;
ll arr[200001];
ll ans[200001];
ll diff[200001];
int main(){
ll n,q,s,t;
cin >> n >> q >> s >> t;
n++;
for(int i=0; i<n; i++){
cin >> arr[i];
}
while(q--){
ll l,r,c;
cin >> l >> r >> c;
for(ll i=l; i<=r; i++){
arr[i]+=c;
}
ll cur = 0;
for(ll i=1; i<n; i++){
ll diff = abs(arr[i]-arr[i-1]);
if(arr[i]>arr[i-1]){
cur -= (diff*s);
}
else{
cur += (diff*t);
}
}
cout << cur << endl;
}
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... |