# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
152797 | Hideo | Foehn Phenomena (JOI17_foehn_phenomena) | C++14 | 166 ms | 9184 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;
#define ll long long
#define pb push_back
#define mk make_pair
#define fr first
#define sc second
#define vi vector < int >
#define pi pair < int, int >
const int N = 2e5 + 7;
const int INF = 1e9 + 7;
int a[N], val[N], ans;
int n, q, s, t;
main(){
cin >> n >> q >> s >> t;
for (int i = 0; i <= n; i++){
scanf("%d", &a[i]);
if (i && a[i] > a[i - 1])
val[i] = (a[i - 1] - a[i]) * s;
else if (i)
val[i] = (a[i - 1] - a[i]) * t;
ans += val[i];
}
while (q--){
int l, r, x;
scanf("%d%d%d", &l, &r, &x);
a[l] += x;
a[r] += x;
r++;
ans -= (val[l] + val[r]);
if (a[l] > a[l - 1])
val[l] = (a[l - 1] - a[l]) * s;
else
val[l] = (a[l - 1] - a[l]) * t;
if (r <= n){
if (a[r] > a[r - 1])
val[r] = (a[r - 1] - a[r]) * s;
else
val[r] = (a[r - 1] - a[r]) * t;
}
ans += (val[l] + val[r]);
printf("%d\n", ans);
}
}
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... |