#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ff first
#define ss second
#define pii pair<int,int>
#define pb push_back
vector <int> h;
signed main(){
int n, q, s, t;
cin >> n >> q >> s >> t;
n++;
for(int i=0; i<n; i++){
int a;
cin >> a;
h.pb(a);
}
vector <int> ans;
while(q--){
int l, r, x;
cin >> l >> r >> x;
for(int i=l; i<=r; i++){
h[i]+=x;
}
int now=0;
for(int i=0; i<n-1; i++){
if(h[i] < h[i+1]) now-=abs(h[i]-h[i+1])*s;
else now += abs(h[i]-h[i+1])*t;
}
ans.pb(now);
}
for(auto x:ans) cout << x << endl;
// If Ai < Ai+1, the temperature of the wind decreases by S degrees per altitude.
// If Ai ≧ Ai+1, the temperature of the wind increases by T degrees per altitude.
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |