# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
153273 | Hideo | Foehn Phenomena (JOI17_foehn_phenomena) | C++14 | 188 ms | 16464 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 = 1e6 + 7;
const int INF = 1e9 + 7;
vector < ll > vec;
ll a[N], val[N], sum[N], ans;
ll n, q, s, t;
main(){
cin >> n >> q >> s >> t;
for (int i = 0; i <= n; i++){
scanf("%lld", &a[i]);
if (i)
val[i] = a[i - 1] - a[i];
sum[i] = val[i];
if (sum[i] > 0)
sum[i] *= t;
else
sum[i] *= s;
ans += sum[i];
}
while (q--){
ll l, r, x;
scanf("%lld%lld%lld", &l, &r, &x);
r++;
val[l] -= x;
if (r <= n)
val[r] += x;
ans -= (sum[l] + sum[r]);
sum[l] = val[l]; sum[r] = val[r];
if (sum[l] > 0)
sum[l] *= t;
else
sum[l] *= s;
if (sum[r] > 0)
sum[r] *= t;
else
sum[r] *= s;
ans += (sum[l] + sum[r]);
vec.pb(ans);
}
for (ll to : vec)
printf("%lld\n", to);
}
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... |