이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1e6 + 66;
ll a[N], S, T, All;
int n, q;
ll get(int i) {
if (i >= n || i < 0) return 0;
if (a[i] < a[i + 1]) {
return (a[i] - a[i + 1]) * S;
} else {
return (a[i] - a[i + 1]) * T;
}
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0), 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) {
All += get(i);
}
while (q--) {
int l, r; ll x;
cin >> l >> r >> x;
All -= get(l-1);
All -= get(r);
for (int i = l ; i <= r ; ++ i) {
a[i] += x;
}
All += get(l-1);
All += get(r);
cout << All << "\n";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |