제출 #51505

#제출 시각아이디문제언어결과실행 시간메모리
51505mergesortFoehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
185 ms7588 KiB
#include<bits/stdc++.h> using namespace std; #define int long long int a[200005],b[200005]; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); int n,q,s,t,ans=0; cin>>n>>q>>s>>t; for(int i=0;i<=n;++i){ cin>>a[i]; } for(int i=1;i<=n;++i){ b[i]=a[i]-a[i-1]; if(a[i]>a[i-1])ans-=(a[i]-a[i-1])*s; else ans-=(a[i]-a[i-1])*t; } while(q--){ int l,r,val; cin>>l>>r>>val; if(r!=n)ans+=b[r+1]*((b[r+1]>0)?s:t); if(l)ans+=b[l]*((b[l]>0)?s:t); if(r!=n)b[r+1]-=val; if(l)b[l]+=val; ans-=b[r+1]*((b[r+1]>=0)?s:t); ans-=b[l]*((b[l]>=0)?s:t); cout<<ans<<'\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...