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 fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define mll map<ll, ll>
#define fi first
#define se second
ll n, q, s, t, l, r, d, add, sub, temp;
ll a[200001];
void f(ll p, ll d) {
if (p < 1 or p > n) {
return;
}
if (a[p] > 0) {
add -= a[p];
} else {
sub += a[p];
}
a[p] += d;
if (a[p] > 0) {
add += a[p];
} else {
sub -= a[p];
}
}
int main() {
fastio;
cin >> n >> q >> s >> t;
for (int i = 0; i <= n; i++) {
cin >> a[i];
a[i] -= temp;
if (a[i] > 0) {
add += a[i];
} else {
sub -= a[i];
}
temp += a[i];
}
for (int i = 0; i < q; i++) {
cin >> l >> r >> d;
f(l, d);
f(r+1, -d);
cout << -(add*s-sub*t) << endl;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |