# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
33259 | minkank | Foehn Phenomena (JOI17_foehn_phenomena) | C++14 | 243 ms | 3576 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>
using namespace std;
const int N = 2e5 + 5;
int n, m, s, t;
long long ans = 0, a[N];
int main() {
scanf("%d %d %d %d", &n, &m, &t, &s);
for(int i = 0; i <= n; ++i) scanf("%lld", &a[i]);
for(int i = n; i >= 1; --i) {
a[i] -= a[i - 1];
if(a[i] > 0) ans -= a[i] * t;
else ans += -a[i] * s;
}
for(int i = 0; i < m; ++i) {
int l, r, x; scanf("%d %d %d", &l, &r, &x);
if(a[l] > 0) ans += a[l] * t;
else ans -= -a[l] * s;
a[l] += x;
if(a[l] > 0) ans -= a[l] * t;
else ans += -a[l] * s;
if(r != n) {
if(a[r + 1] > 0) ans += a[r + 1] * t;
else ans -= -a[r + 1] * s;
a[r + 1] -= x;
if(a[r + 1] > 0) ans -= a[r + 1] * t;
else ans += -a[r + 1] * s;
}
cout << ans << '\n';
}
}
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... |