This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/*
author: lunchbox
problem link: https://oj.uz/problem/view/JOI17_foehn_phenomena
*/
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0), cin.tie(0);
int n, q, s, t; cin >> n >> q >> s >> t, n++;
vector<int> a(n); for (int& x : a) cin >> x;
vector<long long> d(n - 1);
long long c = 0;
auto upd = [&](int i, int x) {
c -= d[i] * (d[i] >= 0 ? t : s);
d[i] += x;
c += d[i] * (d[i] >= 0 ? t : s);
};
for (int i = 0; i < n - 1; i++) upd(i, a[i] - a[i + 1]);
while (q--) {
int l, r, x; cin >> l >> r >> x;
upd(l - 1, -x);
if (r < n - 1) upd(r, +x);
cout << c << '\n';
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |