# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
842656 | EntityPlantt | Foehn Phenomena (JOI17_foehn_phenomena) | C++17 | 95 ms | 11576 KiB |
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 <cstdio>
#define int long long
const int mxn = 200005;
int n, q, s, t, h1, h2, delta[mxn], i, res, l, r, x;
signed main() {
scanf("%lld%lld%lld%lld%lld", &n, &q, &s, &t, &h1);
for (i = 0; i < n; i++) {
scanf("%lld", &h2);
delta[i] = h2 - h1;
if (delta[i] > 0) res -= s * delta[i];
else res -= t * delta[i];
h1 = h2;
}
while (q--) {
scanf("%lld%lld%lld", &l, &r, &x);
l--;
if (l >= 0) {
if (delta[l] > 0) res += s * delta[l];
else res += t * delta[l];
delta[l] += x;
if (delta[l] > 0) res -= s * delta[l];
else res -= t * delta[l];
}
if (r < n) {
if (delta[r] > 0) res += s * delta[r];
else res += t * delta[r];
delta[r] -= x;
if (delta[r] > 0) res -= s * delta[r];
else res -= t * delta[r];
}
printf("%lld\n", res);
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |