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>
typedef long long ll;
using namespace std;
const int N = 2e5 + 500;
ll n , Q , S , T;
ll d[N];
ll pos , neg , last;
void upd(int p , ll X){
if(p > n) return;
if(d[p] > 0) pos -= d[p];
else neg += d[p];
d[p] += X;
if(d[p] > 0) pos += d[p];
else neg -= d[p];
}
int main (){
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> n >> Q >> S >> T;
for(int i = 0; i <= n; ++i){
cin >> d[i];
d[i] -= last;
if(d[i] > 0) pos += d[i];
else neg -= d[i];
last += d[i];
}
while(Q--){
int l , r;
ll x;
cin >> l >> r >> x;
upd(l , x); upd(r + 1 , -x);
cout << ll(neg*T - pos * S) << endl;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |