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);
int n,q,s,t; cin>>n>>q>>s>>t;
int suhu[n+1] = {};
for(int i = 0; i < n+1; i++){
cin>>suhu[i];
}
while(q--){
int l = 0, r = 0, x = 0;
int total = 0;
cin>>l>>r>>x;
for(int i = 0; i < n+1; i++){
if(i >= l && i <= r){
suhu[i] += x;
}
}
for(int i = 0; i < n; i++){
if(suhu[i+1] > suhu[i]){
total -= abs(suhu[i+1] - suhu[i]) * s;
}
else if(suhu[i+1] < suhu[i]){
total += abs(suhu[i+1] - suhu[i]) * t;
}
}
cout<<total<<"\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... |