# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
705287 | rainboy | Foehn Phenomena (JOI17_foehn_phenomena) | C11 | 140 ms | 11492 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 <stdio.h>
#define N 200000
int main() {
static long long aa[N + 1];
int n, q, s, t, i;
long long ans;
scanf("%d%d%d%d", &n, &q, &s, &t);
for (i = 0; i <= n; i++)
scanf("%lld", &aa[i]);
for (i = n; i > 0; i--)
aa[i] -= aa[i - 1];
ans = 0;
for (i = 1; i <= n; i++)
ans -= aa[i] > 0 ? s * aa[i] : t * aa[i];
while (q--) {
int l, r, x;
scanf("%d%d%d", &l, &r, &x);
ans += aa[l] > 0 ? s * aa[l] : t * aa[l];
aa[l] += x;
ans -= aa[l] > 0 ? s * aa[l] : t * aa[l];
if (r < n) {
ans += aa[r + 1] > 0 ? s * aa[r + 1] : t * aa[r + 1];
aa[r + 1] -= x;
ans -= aa[r + 1] > 0 ? s * aa[r + 1] : t * aa[r + 1];
}
printf("%lld\n", ans);
}
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... |