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 int long long
using namespace std;
const int MAXN = 200000;
int n, q, s, t;
int l, r, x;
int a[MAXN+1];
int d[MAXN+1];
int ans;
signed main() {
ios_base::sync_with_stdio(0), cin.tie(0);
cin >> n >> q >> s >> t;
for (int i = 0; i <= n; i++) {
cin >> a[i];
if (i) d[i] = a[i] - a[i-1];
}
for (int i = 1; i <= n; i++)
ans += -(d[i] > 0 ? s : t) * d[i];
for (int i = 1; i <= q; i++) {
cin >> l >> r >> x;
ans -= -(d[l] > 0 ? s : t) * d[l];
d[l] += x;
ans += -(d[l] > 0 ? s : t) * d[l];
if (r < n) {
ans -= -(d[r+1] > 0 ? s : t) * d[r+1];
d[r+1] -= x;
ans += -(d[r+1] > 0 ? s : t) * d[r+1];
}
cout << ans << "\n";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |