제출 #129278

#제출 시각아이디문제언어결과실행 시간메모리
129278tuanasanhFoehn Phenomena (JOI17_foehn_phenomena)C++11
100 / 100
162 ms13304 KiB
#include<bits/stdc++.h> #pragma GCC optimize ("O3") #pragma GCC target ("sse4") #define int long long using namespace std; const int N=2e5+50; int n,q,s,t,ans=0,l,r,k; int a[N],dif[N]; int provjp(int x){ if(x>0) return -s*x; else return -t*x; } signed main(){ // freopen(".inp","r",stdin); // freopen(".out","w",stdout); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n>>q>>s>>t; for(int i=0;i<=n;i++){ cin>>a[i]; dif[i]=a[i]-a[i-1]; if(i>0) ans+=provjp(dif[i]); } while(q--){ cin>>l>>r>>k; ans-=provjp(dif[l]); dif[l]+=k; ans+=provjp(dif[l]); if(r<n){ ans-=provjp(dif[r+1]); dif[r+1]-=k; ans+=provjp(dif[r+1]); } cout<<ans<<"\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...