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>
#define ll long long;
using namespace std;
int main(){
long long n,q,s,t,hasil;
cin>>n>>q>>s>>t;
long long a[n], b[n];
long long l,r,x,naik,turun;
for(int i=0; i<=n; i++){
cin>>a[i];
b[i]=a[i];
}
for(int z=0; z<q; z++){
cin>>l>>r>>x;
for(int d=0; d<=n; d++){
a[d]=b[d];
}
for(int c=l; c<=r; c++){
a[c] += x;
}
hasil = 0;
naik = 0;
turun = 0;
for(int y=0; y<n; y++){
if(a[y]>a[y+1]){
turun += a[y]-a[y+1];
}
if(a[y]<a[y+1]){
naik += a[y+1]-a[y];
}
}
naik = naik * s;
turun = turun * t;
hasil = turun-naik;
cout<<hasil<<endl;
}
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... |