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;
ll s, t;
ll dif[300005];
ll get(ll d) {
if (d > 0) return -s*d;
else return -t*d;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, q; cin >> n >> q >> s >> t;
vector<int> a(n+1);
for (int i = 0; i <= n; i++) cin >> a[i];
ll ans = 0;
for (int i = 0; i < n; i++) {
dif[i] = a[i+1]-a[i];
ans += get(dif[i]);
}
while (q--) {
int l, r, x; cin >> l >> r >> x;
ans -= get(dif[l-1]);
dif[l-1] += x;
ans += get(dif[l-1]);
if (r != n) {
ans -= get(dif[r]);
dif[r] -= x;
ans += get(dif[r]);
}
cout << ans << '\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... |