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>
#include <fstream>
using namespace std;
const int nmax=200005;
long long a[nmax];
long long s,t,ans,k;
int n,q,i,l,r;
long long calc(long long x)
{
if(x>0) return -x*s;
return -x*t;
}
int main()
{
//freopen("data.in","r",stdin);
cin>>n>>q>>s>>t;
for(i=0;i<=n;i++)
cin>>a[i];
for(i=n;i>=1;i--)
{
a[i]=a[i]-a[i-1];
ans+=calc(a[i]);
}
for(int cnt=1;cnt<=q;cnt++)
{
cin>>l>>r>>k;
ans-=calc(a[l]);
if(r<n)ans-=calc(a[r+1]);
a[l]+=k;
a[r+1]-=k;
ans+=calc(a[l]);
if(r<n)ans+=calc(a[r+1]);
cout<<ans<<'\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... |