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(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, q, s, t;
cin >> n >> q >> s >> t;
vector<int> amplitudes;
int temps[n + 1] = {0};
int l, r, x;
cin >> x;
amplitudes.push_back(x);
for(int i = 1; i <= n; i++){
cin >> x;
amplitudes.push_back(x);
}
for(int k = 0; k < q; k++){
cin >> l >> r >> x;
for(int j = l; j <= r; j++){
amplitudes[j] += x;
}
temps[0] = 0;
for(int i = 1; i <= n; i++){
if(amplitudes[i - 1] >= amplitudes[i]){
temps[i] = temps[i - 1] + t * (amplitudes[i - 1] - amplitudes[i]);
}else{
temps[i] = temps[i - 1] - s * (amplitudes[i] - amplitudes[i - 1]);
}
}
cout << temps[n] << 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... |