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 n,q,s,t;
long long ans;
long long a[200005];
void add(int i)
{
if(i > n)
return;
if(a[i] > 0)
ans -= a[i]*s;
else
ans -= a[i]*t;
}
void del(int i)
{
if(i > n)
return;
if(a[i] > 0)
ans += a[i]*s;
else
ans += a[i]*t;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cin>>n>>q>>s>>t;
cin>>a[0];
for(int i=1;i<=n;i++)
cin>>a[i];
for(int i=n;i>=1;i--)
{
a[i]-=a[i-1];
add(i);
}
//cout<<ans<<'\n';
while(q)
{
q--;
int l, r, x;
cin>>l>>r>>x;
del(l);
del(r+1);
a[l]+=x;
a[r+1]-=x;
add(l);
add(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... |