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;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define sc second
#define th third
#define fo fourth
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ldb double
#define endl "\n"
#define MAXN 200007
ll dis[MAXN],s,t,last,a,b;
int n,q;
void upd(int p,ll d)
{
if(p<1 || p>n) return;
if(dis[p]>0) a-=dis[p];
else b+=dis[p];
dis[p]+=d;
if(dis[p]>0) a+=dis[p];
else b-=dis[p];
}
int main()
{
ios::sync_with_stdio(false); cin.tie(0);
cin>>n>>q>>s>>t;
for(int i=0;i<=n;i++)
{
cin>>dis[i];
dis[i]-=last;
if(dis[i]>0) a+=dis[i];
else b-=dis[i];
last+=dis[i];
}
for(int i=0;i<q;i++)
{
int l,r;
ll x;
cin>>l>>r>>x;
upd(l,x),upd(r+1,-x);
cout<<ll(b*t-a*s)<<endl;
}
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... |