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>
const char nl = '\n';
using namespace std;
using ll = long long;
const ll N = 2e5 + 10;
ll n, q, s, t;
ll a[N];
void solve() {
cin >> n >> q >> s >> t;
for (ll i = 0; i <= n; i ++) {
cin >> a[i];
}
while (q --) {
ll l, r, x;
cin >> l >> r >> x;
for (ll i = l; i <= r; i ++) {
a[i] += x;
}
ll wd = 0;
for (ll i = 0; i < n; i ++) {
if (a[i] < a[i+1]) {
wd -= (a[i+1] - a[i]) * s;
} else {
wd += (a[i] - a[i+1]) * t;
}
}
cout << wd << nl;
}
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
ll tst = 1;
// cin >> tst;
while (tst --) {
solve();
cout << nl;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |