# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
33250 | ngkan146 | Foehn Phenomena (JOI17_foehn_phenomena) | C++98 | 229 ms | 5140 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 ll long long
using namespace std;
ll n,q,s,t;
ll a[200005], b[200005];
int main(){
scanf("%lld %lld %lld %lld",&n,&q,&s,&t);
for(int i=0;i<=n;i++) scanf("%lld",&a[i]);
for(int i=1;i<=n;i++) b[i] = a[i] - a[i-1];
ll res = 0;
for(int i=1;i<=n;i++)
if (b[i] <= 0) res += t * abs(b[i]);
else res -= s * b[i];
while(q--){
int l,r,x;
scanf("%d %d %d",&l,&r,&x);
if (b[l] <= 0) res -= t * abs(b[l]);
else res += s * b[l];
b[l] += x;
if (b[l] <= 0) res += t * abs(b[l]);
else res -= s * b[l];
if (r+1 <= n){
if (b[r+1] <= 0) res -= t * abs(b[r+1]);
else res += s * b[r+1];
b[r+1] -= x;
if (b[r+1] <= 0) res += t * abs(b[r+1]);
else res -= s * b[r+1];
}
printf("%lld\n",res);
}
}
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... |