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;
using lint=long long;
const int INF=0x3f3f3f3f;
const lint LINF=0x3f3f3f3f3f3f3f3f;
namespace Type{
using pair_int=std::pair<int,int>;
using pair_lint=std::pair<lint,lint>;
using pair_real=std::pair<double,double>;
using vector_int=vector<int>;
using vector_lint=vector<lint>;
using vector2d_int=vector<vector<int>>;
using vector2d_lint=vector<vector<lint>>;
}
//#define FILE_IO
#define SINGLE_TEST
//#define MULTI_TEST
void solve(){
int n,q,s,t;
cin>>n>>q>>s>>t;
lint last=0,ans=0;
auto calc=[&](lint val){
if(val>=0) return -t*val;
return -val*s;
};
Type::vector_lint diff(n+10);
for(int i=0;i<=n;i++){
lint temp;
cin>>temp;
diff[i]=temp-last;
last=temp;
ans+=calc(diff[i]);
}
for(int i=1;i<=q;i++){
lint left,right,k;
cin>>left>>right>>k;
ans-=calc(diff[left]);
diff[left]+=k;
ans+=calc(diff[left]);
if(right<n){
ans-=calc(diff[right+1]);
diff[right+1]-=k;
ans+=calc(diff[right+1]);
}
cout<<ans<<"\n";
}
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
#ifdef FILE_IO
freopen("../text.in","r",stdin);
#endif
int T;
#ifdef SINGLE_TEST
T=1;
#endif
#ifdef MULTI_TEST
cin>>T;
#endif
while(T--) solve();
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... |