#include<bits/stdc++.h>
using namespace std;
#define task "a"
#define se second
#define fi first
#define ll long long
#define ii pair<ll, ll>
const long mxN = 2e5 + 7;
ll dwn, up, a[mxN], dif[mxN];
int n, q;
ll Change(ll j)
{
if (j > 0)
return j * dwn;
return j * up;
}
ll Upd(int j, ll val)
{
if (j > n)
return 0;
ll res = Change(dif[j]);
dif[j] += val;
return res - Change(dif[j]);
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
//freopen(task".INP", "r", stdin);
//freopen(task".OUT", "w", stdout);
cin >> n >> q >> dwn >> up;
ll ans = 0;
for (int i = 0; i <= n; i++)
{
cin >> a[i];
if (!i)
continue;
dif[i] = a[i] - a[i - 1];
ans -= Change(dif[i]);
}
for (int i = 1; i <= q; i++)
{
int l, r;
ll val;
cin >> l >> r >> val;
ans += Upd(l, val) + Upd(r + 1, -val);
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... |