이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int n, q, s, t;
int a[N];
long long d[N];
long long ans = 0;
long long eval(int idx) {
return (d[idx] > 0 ? 1LL * -s * d[idx] : 1LL * t * -d[idx]);
}
void upd(int idx, int val) {
ans -= eval(idx);
d[idx] += val;
ans += eval(idx);
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n >> q >> s >> t;
for (int i = 0; i <= n; i++) {
cin >> a[i];
if (i > 0) {
upd(i, a[i] - a[i - 1]);
}
}
while (q--) {
int l, r, x;
cin >> l >> r >> x;
upd(l, +x);
if (r + 1 <= n) {
upd(r + 1, -x);
}
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... |