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;
using ll = long long;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int n, q, s, t;
cin >> n >> q >> s >> t;
vector<ll> d;
int last = 0;
for(int i = 0; i < n + 1; i++) {
int x;
cin >> x;
if(i) {
d.push_back(x - last);
}
last = x;
}
auto calculate_val = [&](ll x) -> ll {
if(x < 0) return x * t;
else return x * s;
};
ll cur = 0;
for(ll x : d) {
cur += calculate_val(x);
}
for(int i = 0; i < q; i++) {
int l, r, x;
cin >> l >> r >> x;
cur -= calculate_val(d[l - 1]);
d[l - 1] += x;
cur += calculate_val(d[l - 1]);
if(r != n) {
cur -= calculate_val(d[r]);
d[r] -= x;
cur += calculate_val(d[r]);
}
cout << -cur << "\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... |