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 int long long
const int MXN = 200005;
int n, q, s, t;
int diff[MXN]; // diff[i] -> i-1 to i
int height[MXN];
int temp;
int get(int of) {
if (of > 0) return -s * of;
else return abs(t * of);
}
void upd(int pos, int by) {
temp -= get(diff[pos]);
diff[pos] += by;
temp += get(diff[pos]);
}
signed main() {
cin >> n >> q >> s >> t;
for (int i=0; i<=n; i++) {
cin >> height[i];
}
for (int i=1; i<=n; i++) {
diff[i] = height[i] - height[i-1];
temp += get(diff[i]);
}
for (int i=0; i<q; i++) {
int l, r, x;
cin >> l >> r >> x;
upd(l, x);
if (r < n) upd(r+1, -x);
cout << temp << 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... |