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;
const long long N=2e5+5,mod=1e9+7;
long long a[N],b[N],q,s,t,n,cur;
void add(long long i,long long f){
if(i>n) return;
if(b[i]>0) cur-=s*b[i]*f;
else cur-=t*b[i]*f;
}
int main(){
cin>>n>>q>>s>>t;
for(long long i=0;i<=n;i++){
cin >> a[i];
if(i)b[i]=a[i]-a[i-1];
add(i,1);
}
while(q--){
long long l,r,x;
cin>>l>>r>>x;
add(l,-1);
add(r+1,-1);
b[l]+=x;
b[r+1]-=x;
add(l,1);
add(r+1,1); cout<<cur<<endl;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |