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;
int main(){
int N, Q, S, T;
cin >> N >> Q >> S >> T;
int A[N+1];
for (int i = 0; i <= N; i++){
cin >> A[i];
}
int L[Q], R[Q], X[Q];
for (int i = 0; i < Q; i++){
cin >> L[i] >> R[i] >> X[i];
int B[N+1];
for (int j = 0; j <= N; j++){
B[j] = A[j];
}
for (int j = L[i]; j <= R[i]; j++){
B[j] += X[i];
}
int ans = 0;
for (int j = 1; j <= N; j++){
if ((B[j] - B[j-1]) > 0){
ans -= (B[j] - B[j-1]) * S;
}
else{
ans += (B[j] - B[j-1]) * T * (-1);
}
}
cout << ans << endl;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |