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;
#define int long long
typedef pair<int, int> pii;
#define endl '\n'
const int MXN = 200005;
int n, q, s, t, a[MXN], d[MXN], ans;
int l, r, x;
inline int f(int id) {
if (d[id] >= 0) return d[id] * s;
else return d[id] * t;
}
int32_t main() {
cin.tie(0) -> sync_with_stdio(false);
cout.tie(0);
cin >> n >> q >> s >> t;
for (int i = 0; i <= n; i++) {
cin >> a[i];
}
for (int i = 0; i < n; i++) {
d[i] = a[i + 1] - a[i];
ans -= f(i);
}
// for (int i = 0; i < n; i++) cout << d[i] << ' ';
// cout << endl;
// cout << ans << endl;
while (q--) {
cin >> l >> r >> x;
l--;
ans += f(l);
if (r < n) ans += f(r);
d[l] += x;
d[r] -= x;
ans -= f(l);
if (r < n) ans -= f(r);
// for (int i = 0; i < n; i++) cout << d[i] << ' ';
// cout << endl;
cout << ans << endl;
}
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... |