이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |