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 MAXN 200200
typedef long long ll;
ll delta[MAXN], s, t, last, pos, neg;
int n, q;
void upd(int p, ll d){
if(p<1 or p>n) return;
if(delta[p]>0) pos-=delta[p];
else neg+=delta[p];
delta[p]+=d;
if(delta[p]>0) pos+=delta[p];
else neg-=delta[p];
}
int main(){
cin >> n >> q >> s >> t;
for(int i=0;i<=n;i++){
cin >> delta[i];
delta[i]-=last;
if(delta[i]>0) pos+=delta[i];
else neg-=delta[i];
last+=delta[i];
}
for(int i=0;i<q;i++){
int l, r;
ll d;
cin >> l >> r >> d;
upd(l,d), upd(r+1,-d);
cout << ll(neg*t-pos*s) << "\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... |