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 int64_t
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ar = array<int, 2>;
const int64_t INF = 1ll << 60;
const int N = 2e5 + 5;
int n, q, a[N], S, T, sum;
void add(int x, const int d = 1) {
sum -= d * (x > 0 ? S : T) * x;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> q >> S >> T;
FOR(i, 0, n + 1) cin >> a[i];
FOR(i, 0, n) {
a[i] = a[i + 1] - a[i];
add(a[i]);
}
while (q--) {
int l, r, x;
cin >> l >> r >> x;
--l;
if (r < n) {
add(a[r], -1);
a[r] -= x;
add(a[r]);
}
if (l >= 0) {
add(a[l], -1);
a[l] += x;
add(a[l]);
}
cout << sum << '\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... |