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<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N = 2e5 + 8;
int n, q, s, t;
ll a[N], d[N];
ll get(ll x) {
if (x > 0)
return -x * s;
return -x * t;
}
int main() {
cin.tie(NULL)->sync_with_stdio(false);
cin >> n >> q >> s >> t;
for (int i = 0; i <= n; ++i) cin >> a[i];
for (int i = 1; i <= n; ++i) d[i] = a[i] - a[i - 1];
ll sum(0);
for (int i = 1; i <= n; ++i)
sum += get(d[i]);
int l, r, x; while (q--) {
cin >> l >> r >> x; // l and r+1
sum -= get(d[l]);
d[l] += x;
sum += get(d[l]);
if (r != n) {
sum -= get(d[r + 1]);
d[r + 1] -= x;
sum += get(d[r + 1]);
}
cout << sum << '\n';
}
}
/** /\_/\
* (= ._.)
* / >0 \>1
**/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |