This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// Success consists of going from failure to failure without loss of enthusiasm
#include <bits/stdc++.h>
using namespace std;
#define nl '\n'
using ll = long long;
template<class T> using V = vector<int>;
int main() {
cin.tie(0)->sync_with_stdio(0);
int N, M, S, T; cin >> N >> M >> S >> T;
V<ll> A(N+1); for(auto& x : A) cin >> x;
ll ans = 0;
V<ll> D(N); for(int i = 0; i < N; i++) D[i] = A[i] - A[i + 1];
auto upd = [&](int x, ll t) {
if (D[x] < 0) ans += S * t * D[x];
else ans += T * t * D[x];
};
for(int i = 0; i < N; i++) upd(i, +1);
for(int q = 0; q < M; q++) {
int l, r, x; cin >> l >> r >> x;
{
upd(l - 1, -1);
D[l - 1] -= x;
upd(l - 1, +1);
}
if (r < N) {
upd(r, -1);
D[r] += x;
upd(r, +1);
}
cout << ans << nl;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |