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;
const int N = 200001;
long long diff[N];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n, q, s, t;
cin >> n >> q >> s >> t;
for (int i = 0; i <= n; ++i) {
cin >> diff[i];
}
adjacent_difference(diff, diff + n + 1, diff);
long long wind = 0;
for (int i = 0; i <= n; ++i) {
wind -= (diff[i] < 0 ? t : s) * diff[i];
}
while (q--) {
int l, r, x;
cin >> l >> r >> x;
wind += (diff[l] < 0 ? t : s) * diff[l];
diff[l] += x;
wind -= (diff[l] < 0 ? t : s) * diff[l];
if (r < n) {
wind += (diff[r + 1] < 0 ? t : s) * diff[r + 1];
diff[r + 1] -= x;
wind -= (diff[r + 1] < 0 ? t : s) * diff[r + 1];
}
cout << wind << "\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... |