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 ll long long
ll n, q, s, t, d[200000], up = 0, down = 0;
void update(ll p, ll x) {
if (p < 1 or p > n) return;
if (d[p] > 0)
up -= d[p];
else
down += d[p];
d[p] += x;
if (d[p] > 0)
up += d[p];
else
down -= d[p];
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> q >> s >> t;
ll last = 0;
for (ll i = 0; i <= n; ++i) {
cin >> d[i];
d[i] -= last;
if (d[i] > 0)
up += d[i];
else
down -= d[i];
last += d[i];
}
for (ll i = 0; i < q; ++i) {
ll l, r, x;
cin >> l >> r >> x;
update(l, x);
update(r + 1, -x);
cout << t * down - s * up << '\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... |