This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
int n, q, s, t;
int a[maxn];
long long delta[maxn];
void fastIO()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
int main()
{
fastIO();
cin >> n >> q >> s >> t;
for (int i = 1; i <= n + 1; ++i)
{
cin >> a[i];
}
for (int i = 1; i <= n; ++i)
{
delta[i] = a[i] - a[i + 1];
}
for (int i = 1; i <= q; ++i)
{
int l, r, val;
cin >> l >> r >> val;
if (l != 0)
{
delta[l] -= val;
}
if (r != n)
{
delta[r + 1] += val;
}
long long ans = 0;
for (int j = 1; j <= n; ++j)
{
if (delta[j] < 0)
{
ans += delta[j] * (1LL * s);
}
else
{
ans += delta[j] * (1LL * t);
}
}
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... |