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 ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
ll n,q,s,t,i,a[202020],has,sel[202020],ta,tb,tc,tem;
ll eh(ll aa)
{
if(sel[aa]>0)
return -s*sel[aa];
else
return -t*sel[aa];
}
int main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>n>>q>>s>>t;
for(i=0;i<=n;i++)
cin>>a[i];
for(i=1;i<=n;i++)
sel[i]=a[i]-a[i-1];
for(i=1;i<=n;i++)
if(sel[i]>0)
has-=s*sel[i];
else
has-=t*sel[i];
while(q--)
{
cin>>ta>>tb>>tc;
tem=eh(ta)+eh(tb+1);
sel[ta]+=tc;
if(tb<n)
sel[tb+1]-=tc;
has+=eh(ta)+eh(tb+1)-tem;
cout<<has<<"\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... |