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 <iostream>
int A[200001];
int chk[200001];
int sum = 0;
int n, q, s, t;
inline int calc(int x)
{
return (x < 0 ? x * s : x * t);
}
signed main()
{
// freopen("foehn.inp", "r", stdin);
// Fast I/O
std::cin.tie(0);
std::cout.tie(0);
std::ios_base::sync_with_stdio(false);
std::cin >> n >> q >> s >> t;
for (int i = 0; i <= n; ++i)
{
std::cin >> A[i];
}
for (int i = 1; i <= n; ++i)
{
chk[i] = A[i - 1] - A[i];
sum += calc(chk[i]);
}
while (q-- > 0)
{
int l, r, x;
std::cin >> l >> r >> x;
if (l > 0)
{
sum -= calc(chk[l]);
chk[l] -= x;
sum += calc(chk[l]);
}
if (r < n)
{
sum -= calc(chk[r + 1]);
chk[r + 1] += x;
sum += calc(chk[r + 1]);
}
std::cout << sum << '\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... |