#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
void sol()
{
int n, q, s, t;
cin >> n >> q >> s >> t;
vector<int> a;
int ai;
for(int i = 0; i < n + 1; i++) {
cin >> ai;
a.pb(ai);
}
vector<int> b = a;
int x, y, z;
int wind = 0;
for(int i = 0; i < q; i++) {
cin >> x >> y >> z;
for(int j = x; j <= y; j++) a[j] += z;
for(int j = 0; j < a.size() - 1; j++) {
if(a[j] < a[j + 1]) {
wind -= s * (a[j + 1] - a[j]);
} else {
wind += t * (a[j] - a[j + 1]);
}
}
cout << wind << '\n';
wind = 0;
a = b;
}
}
int32_t main()
{
ios::sync_with_stdio(false);
cin.tie(0);
sol();
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... |