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 long long
using namespace std;
signed main() {
ios_base::sync_with_stdio(0), cin.tie(0);
int n, q, s, t;
cin >> n >> q >> s >> t;
vector<int> diff(n);
int prv = 0;
cin >> prv;
int curans = 0;
auto conv = [&](int x) {
if (x < 0)
return -x * t;
return -x * s;
};
for (int i = 0; i < n; ++i) {
int cur;
cin >> cur;
diff[i] = cur - prv;
curans += conv(diff[i]);
prv = cur;
}
while (q--) {
int li, ri, xi;
cin >> li >> ri >> xi;
curans -= conv(diff[li - 1]);
diff[li - 1] += xi;
curans += conv(diff[li - 1]);
if (ri != n) {
curans -= conv(diff[ri]);
diff[ri] -= xi;
curans += conv(diff[ri]);
}
cout << curans << '\n';
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |