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;
using ll = long long;
ll N, Q, S, T;
ll A[200005];
ll f(ll k){
return (A[k] > 0 ? -S * A[k] : -T * A[k]);
}
int main(){
cin.tie(0) -> sync_with_stdio(false);
cin >> N >> Q >> S >> T;
ll r = 0;
for(int i = 0; i <= N; i++){
cin >> A[i];
}
for(int i = N; i >= 1; i--){
A[i] -= A[i - 1];
r += f(i);
}
while(Q--){
ll L, R, X; cin >> L >> R >> X;
r -= f(L); A[L] += X; r += f(L);
if(R + 1 <= N) {
r -= f(R + 1); A[R + 1] -= X; r += f(R + 1);
}
cout << r << '\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... |