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 long long MX=2e5+10;
long long a[MX];
long long s,t;
long long cnt(long long zn)
{
if(zn>0)
{
return ((-zn)*s);
}
else
{
return ((-zn)*t);
}
}
int main()
{
cin.tie(0);
ios_base::sync_with_stdio(0);
long long n,q;
cin>>n>>q>>s>>t;
for(long long i=0;i<=n;i++)
{
cin>>a[i];
}
for(long long i=n;i>=1;i--)
{
a[i]-=a[i-1];
}
long long tmp=0;
for(long long i=1;i<=n;i++)
{
tmp+=cnt(a[i]);
//cout<<a[i]<<" "<<cnt(a[i])<<"\n";
}
//cout<<tmp<<"\n";
long long l,r,x;
while(q--)
{
cin>>l>>r>>x;
tmp-=cnt(a[l]);
a[l]+=x;
tmp+=cnt(a[l]);
if(r!=n)
{
tmp-=cnt(a[r+1]);
a[r+1]-=x;
tmp+=cnt(a[r+1]);
}
cout<<tmp<<"\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... |