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
int main() {
int n, q, s, t;
cin >> n >> q >> s >> t;
vector<ll> a(n+1);
for (int i = 0; i <= n; i++) {
cin >> a[i];
}
vector<ll> diff(n);
ll pos = 0, neg = 0;
for (int i = 1; i <= n; i++) {
diff[i-1] = a[i]-a[i-1];
if (diff[i-1] < 0)
neg += abs(diff[i-1]);
else
pos += diff[i-1];
}
while (q--) {
int l, r, x;
cin >> l >> r >> x;
l--;
if (diff[l] < 0)
neg -= abs(diff[l]);
else
pos -= abs(diff[l]);
diff[l] += x;
if (r < n) {
if (diff[r] < 0)
neg -= abs(diff[r]);
else
pos -= abs(diff[r]);
diff[r] -= x;
}
if (diff[l] < 0)
neg += abs(diff[l]);
else
pos += diff[l];
if (r < n) {
if (diff[r] < 0)
neg += abs(diff[r]);
else
pos += diff[r];
}
cout << neg*t - pos*s << '\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... |