제출 #718152

#제출 시각아이디문제언어결과실행 시간메모리
718152Yell0Foehn Phenomena (JOI17_foehn_phenomena)C++17
100 / 100
139 ms11492 KiB
#include <bits/stdc++.h> #define calc(i) abs(dif[i])*(dif[i]<0?T:-S) using namespace std; typedef long long ll; const int MN=1e6+2; int N,Q; ll S,T,a[MN],dif[MN],ans=0; int main() { ios::sync_with_stdio(0);cin.tie(0); cin>>N>>Q>>S>>T; for(int i=0;i<=N;++i) { cin>>a[i]; if(i) { dif[i]=a[i]-a[i-1]; ans+=calc(i); } } while(Q--) { int l,r,x; cin>>l>>r>>x; if(r<N) { ans-=calc(r+1); dif[r+1]-=x; ans+=calc(r+1); } ans-=calc(l); dif[l]+=x; ans+=calc(l); cout<<ans<<'\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...