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;
typedef long long ll;
ll n, s, q ,t, a[200005], ans = 0, l, r, x, temp;
int main() {
cin >> n >> q >> s >> t;
cin >> temp;
for(int i = 1; i <= n; i++) {
cin >> a[i];
a[i - 1] = temp - a[i];
temp = a[i];
ans += a[i - 1] * (a[i - 1] < 0 ? s : t);
}
for(int i = 0; i < q; i++) {
cin >> l >> r >> x;
l--;
ans -= a[l] * (a[l] < 0 ? s : t);
a[l] -= x;
ans += a[l] * (a[l] < 0 ? s : t);
if(r != n) {
ans -= a[r] * (a[r] < 0 ? s : t);
a[r] += x;
ans += a[r] * (a[r] < 0 ? s : t);
}
cout << ans << endl;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |