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;
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... |