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>
using namespace std;
long long a[200010], b[200010];
int main()
{
int n, q;
long long s, t, v = 0;
cin >> n >> q >> s >> t;
for(int i = 0; i <= n; i++) cin >> a[i];
for(int i = 1; i <= n; i++)
b[i] = a[i] - a[i - 1];
for(int i = 1; i <= n; i++)
{
if(b[i] > 0) v -= s * b[i];
else v -= t * b[i];
}
while(q--)
{
int l, r;
long long x;
cin >> l >> r >> x;
if(b[l] > 0) v += s * b[l];
else v += t * b[l];
b[l] += x;
if(b[l] > 0) v -= s * b[l];
else v -= t * b[l];
if(r != n)
{
if(b[r + 1] > 0) v += s * b[r + 1];
else v += t * b[r + 1];
b[r + 1] -= x;
if(b[r + 1] > 0) v -= s * b[r + 1];
else v -= t * b[r + 1];
}
cout << v << "\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... |