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 num long long
num S, T;
num res = 0;
vector<num> delta;
num compute (num delta) {
delta *= -1;
if (delta < 0) return delta * S;
return delta * T;
}
void addDelta (int index, num value) {
res -= compute(delta[index]);
delta[index] += value;
res += compute(delta[index]);
}
int main () {
int N, Q;
cin >> N >> Q >> S >> T;
delta.resize(N);
int L;
cin >> L;
for (int i = 0; i < N; i ++) {
int x;
cin >> x;
addDelta(i, x - L);
L = x;
}
for (int q = 0; q < Q; q ++) {
int l, r, v;
cin >> l >> r >> v;
addDelta(l - 1, v);
if (r != N)
addDelta(r, - v);
cout << res << 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... |