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