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;
typedef long long ll;
ll N, Q, S, T, X, L, R, diff[200005], cont[200005], init = 0;
ll cost(int x){
if (diff[L] < 0) return T*diff[L];
else return S*diff[L];
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> N >> Q >> S >> T;
S = -S;
T = -T;
for (int i = 0; i <= N; ++i){
cin >> diff[i];
}
for (int i = N; i >= 1; --i){
diff[i] -= diff[i-1];
}
for (int i = 1; i <= N; ++i){
init += cost(i);
}
for (int i = 1; i <= Q; ++i){
cin >> L >> R >> X;
init -= cost(L);
if (R < N) init -= cost(R+1);
diff[L] += X;
diff[R+1] -= X;
init += cost(L);
if (R < N) init += cost(R+1);
cout << init << '\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... |