# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
51485 | FutymyClone | Foehn Phenomena (JOI17_foehn_phenomena) | C++14 | 241 ms | 7612 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 <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 200005;
int a[N], d[N], T[N], n, q, s, t, c[N];
signed main(){
scanf("%lld %lld %lld %lld", &n, &q, &s, &t);
for (int i = 0; i <= n; i++) scanf("%lld", &a[i]);
c[0] = T[0] = 0;
d[0] = 0;
for (int i = 1; i <= n; i++) d[i] = a[i] - a[i - 1];
int ans = 0;
for (int i = 1; i <= n; i++) {
if (d[i] >= 0) ans = ans - d[i] * s;
else ans = ans - d[i] * t;
}
while (q--) {
int l, r, x;
scanf("%lld %lld %lld", &l, &r, &x);
if (d[l] >= 0) ans = ans + d[l] * s;
else ans = ans + d[l] * t;
d[l] += x;
if (d[l] >= 0) ans = ans - d[l] * s;
else ans = ans - d[l] * t;
if (r < n) {
if (d[r + 1] >= 0) ans = ans + d[r + 1] * s;
else ans = ans + d[r + 1] * t;
d[r + 1] -= x;
if (d[r + 1] >= 0) ans = ans - d[r + 1] * s;
else ans = ans - d[r + 1] * t;
}
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... |