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 int long long
#define MOD 1000000007
#define pb push_back
#define bw(i,r,l) for (int i=r-1;i>=l;i--)
#define fw(i,l,r) for (int i=l;i<r;i++)
using namespace std;
const int N=200005;
int ans=0,n,q,S,T,a[N],cur[N];
int get(int x) {
if (x>0) return x*T;
else return S*x;
}
signed main() {
//freopen("aome.inp","r",stdin);
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
cin>>n>>q>>S>>T;
fw (i,0,n+1) cin>>a[i];
fw (i,0,n) {
cur[i]=a[i]-a[i+1];
ans+=get(cur[i]);
}
fw (i,0,q) {
int l,r,x;
cin>>l>>r>>x;
ans-=get(cur[l-1]); if (r<n) ans-=get(cur[r]);
cur[l-1]-=x; if (r<n) cur[r]+=x;
ans+=get(cur[l-1]); if (r<n) ans+=get(cur[r]);
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... |