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"
using namespace std;
#define ar array
#define long long
const int N = 2e5 + 5;
int a[N], d[N];
signed main(){
ios::sync_with_stdio(0); cin.tie(0);
int n, q, s, t; cin>>n>>q>>s>>t;
for(int i=0;i<=n;i++) cin>>a[i];
int res = 0;
auto add = [&](int i, int f){
if(i > n) return;
if(d[i] > 0) res -= s * d[i] * f;
else res -= t * d[i] * f;
};
for(int i=1;i<=n;i++){
d[i] = a[i] - a[i-1];
add(i, 1);
}
for(int f=0;f<q;f++){
int l, r, x; cin>>l>>r>>x;
add(l, -1), add(r+1, -1);
d[l] += x, d[r + 1] -= x;
add(l, 1), add(r+1, 1);
cout<<res<<"\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... |