# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
191329 | Akashi | Foehn Phenomena (JOI17_foehn_phenomena) | C++14 | 188 ms | 12424 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;
int n, q, s, t;
int x[200005];
long long deg;
long long d[200005];
int main()
{
scanf("%d%d%d%d", &n, &q, &s, &t);
for(int i = 1; i <= n + 1 ; ++i) scanf("%d", &x[i]);
for(int i = 1; i <= n ; ++i){
d[i] = x[i] - x[i + 1];
if(d[i] >= 0) deg += 1LL * t * d[i];
else deg += 1LL * s * d[i];
}
int l, r, val;
for(int i = 1; i <= q ; ++i){
scanf("%d%d%d", &l, &r, &val);
++l; ++r;
if(l > 1){
if(d[l - 1] >= 0) deg -= 1LL * t * d[l - 1];
else deg -= 1LL * s * d[l - 1];
d[l - 1] -= val;
if(d[l - 1] >= 0) deg += 1LL * t * d[l - 1];
else deg += 1LL * s * d[l - 1];
}
if(r <= n){
if(d[r] >= 0) deg -= 1LL * t * d[r];
else deg -= 1LL * s * d[r];
d[r] += val;
if(d[r] >= 0) deg += 1LL * t * d[r];
else deg += 1LL * s * d[r];
}
printf("%lld\n", deg);
}
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... |