#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MAXN = 2e5 + 5;
int n, q, s, t;
int a[MAXN];
int d[MAXN];
int ans = 0;
int tinh(int x)
{
if (x > 0)
{
return -x * s;
}
else
{
return -x * t;
}
}
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
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] - a[i - 1];
}
for (int i = 1; i <= n; i++)
{
ans += tinh(d[i]);
}
while(q--)
{
int l, r, k;
cin >> l >> r >> k;
ans -= tinh(d[l]);
d[l] += k;
ans += tinh(d[l]);
if (r < n)
{
ans -= tinh(d[r + 1]);
d[r + 1] -= k;
ans += tinh(d[r + 1]);
}
cout << ans << "\n";
}
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |