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>
#define int ll
using ll = long long;
int const nmax = 200000;
int v[5 + nmax], dif[5 + nmax];
int s, t;
int getvalue(int pos) {
if(0 < dif[pos])
return dif[pos] * t;
else
return dif[pos] * s;
}
signed main() {
std::ios_base::sync_with_stdio(0);
std::cin.tie(0);
int n, q;
std::cin >> n >> q >> s >> t;
for(int i = 0;i <= n; i++)
std::cin >> v[i];
for(int i = 0;i < n; i++)
dif[i] = v[i] - v[i + 1];
ll result = 0;
for(int i = 0;i < n; i++)
result += getvalue(i);
for(int i = 1;i <= q; i++) {
int x, y, val;
std::cin >> x >> y >> val;
result -= getvalue(x - 1);
if(y < n)
result -= getvalue(y);
dif[x - 1] -= val;
if(y < n)
dif[y] += val;
result += getvalue(x - 1);
if(y < n)
result += getvalue(y);
std::cout << result << "\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... |