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;
void solve() {
int N, Q, S, T;
cin >> N >> Q >> S >> T;
vector<long long> A(N + 1);
for (auto &v : A) {
cin >> v;
}
long long sum_neg = 0, sum_pos = 0;
auto Add = [&](long long val, int sign) {
if (val < 0) {
sum_neg += sign * val;
} else {
sum_pos += sign * val;
}
};
vector<long long> D(N);
for (int i = 0; i < N; i++) {
D[i] = A[i + 1] - A[i];
Add(D[i], 1);
}
while (Q--) {
int L, R, X;
cin >> L >> R >> X;
if (R < N) {
Add(D[R], -1);
D[R] -= X;
Add(D[R], 1);
}
Add(D[L - 1], -1);
D[L - 1] += X;
Add(D[L - 1], 1);
cout << -(sum_pos * S + sum_neg * T) << "\n";
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
solve();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |