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;
const int N = 2e5 + 5;
int n, q;
long long s, t;
long long a[N], b[N];
long long res = 0;
long long fuck(long long x) {
if (x < 0) return s * x;
return t * x;
}
int main() {
ios_base::sync_with_stdio(false);
cin >> n >> q >> s >> t;
for (int i = 0;i <= n;++i) cin >> a[i];
for (int i = 1;i <= n;++i) {
b[i] = a[i - 1] - a[i];
res += fuck(b[i]);
}
while (q--) {
int l, r; long long x;
cin >> l >> r >> x;
if (l) {
res -= fuck(b[l]);
b[l] -= x;
res += fuck(b[l]);
}
if (r < n) {
res -= fuck(b[r + 1]);
b[r + 1] += x;
res += fuck(b[r + 1]);
}
cout << res << '\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... |