#include <bits/stdc++.h>
using namespace std;
#ifndef lisie_bimbi
#define endl '\n'
#pragma GCC optimize("O3")
#pragma GCC target("avx,avx2,bmi2,fma")
#endif
using ll = long long;
const ll inf = 1'000'000'000'000'000'000;
using ld = long double;
void solve(){
int n, q;
ll s, t;
cin >> n >> q >> s >> t;
vector<int> z(n + 1);
for(int i = 0; i < n + 1; i++){
cin >> z[i];
}
vector<ll> a(n);
for(int i = 0; i < n; i++){
a[i] = z[i + 1] - z[i];
}
ll now = 0;
for(int i = 0; i < n; i++){
if(a[i] > 0){
now -= s * a[i];
}else{
now -= t * a[i];
}
}
for(int i = 0; i < q; i++){
int l, r, x;
cin >> l >> r >> x;
l--;
if(a[l] > 0){
now += s * a[l];
}else{
now += t * a[l];
}
a[l] += x;
if(a[l] > 0){
now -= s * a[l];
}else{
now -= t * a[l];
}
if(r < n){
if(a[r] > 0){
now += s * a[r];
}else{
now += t * a[r];
}
a[r] -= x;
if(a[r] > 0){
now -= s * a[r];
}else{
now -= t * a[r];
}
}
cout << now << endl;
}
}
signed main(){
#ifdef lisie_bimbi
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#else
#endif
cin.tie(nullptr)->sync_with_stdio(false);
cout << setprecision(20) << fixed;
int t = 1;
//cin >> t;
while(t--){
solve();
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |