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 <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
int main() {
int N, Q;
ll S, T;
cin >> N >> Q >> S >> T;
vector <ll> a(N+1);
for (int i = 0; i <= N; i++)
cin >> a[i];
while (Q--) {
int l, r, x;
cin >> l >> r >> x;
for (int i = l; i <= r; i++)
a[i] += x;
ll ans = 0;
for (int i = 0; i+1 <= N; i++) {
if (a[i] < a[i+1])
ans -= S * (a[i+1] - a[i]);
else
ans += T * (a[i] - a[i+1]);
}
cout << ans << '\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... |