#include <bits/stdc++.h>
using namespace std;
#define int long long
int n, q, s, t, a[200005], d[200005];
int ans = 0;
void update(int pos, int val)
{
ans -= d[pos] * ((d[pos] >= 0) ? t : s);
d[pos] += val;
ans += d[pos] * ((d[pos] >= 0) ? t : s);
}
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> n >> q >> s >> t;
for (int i = 0; i <= n; i++) cin >> a[i];
for (int i = 1; i <= n; i++)
{
d[i] = a[i - 1] - a[i];
}
for (int i = 1; i <= n; i++)
{
ans += d[i] * ((d[i] >= 0) ? t : s);
}
while(q-- > 0)
{
int l, r, x;
cin >> l >> r >> x;
update(l, -x);
if (r < n) update(r + 1, x);
cout << ans << '\n';
}
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... |