제출 #110074

#제출 시각아이디문제언어결과실행 시간메모리
110074maruiiFoehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
197 ms11512 KiB
#include <bits/stdc++.h> using namespace std; long long D[1000001]; int main(){ ios_base::sync_with_stdio(0), cin.tie(0); int N, Q, S, T; cin>>N>>Q>>S>>T; long long ans = 0; for(int i=0, pre=0; i<=N; ++i){ int x; cin>>x; D[i] = x - pre; if(D[i]>0) ans -= S*D[i]; else ans -= T*D[i]; pre = x; } while(Q--){ int s,e,v; cin>>s>>e>>v; if(D[s]>0) ans += S*D[s]; else ans += T*D[s]; D[s] += v; if(D[s]>0) ans -= S*D[s]; else ans -= T*D[s]; if(e<N){ if(D[e+1]>0) ans += S*D[e+1]; else ans += T*D[e+1]; D[e+1] -= v; if(D[e+1]>0) ans -= S*D[e+1]; else ans -= T*D[e+1]; } cout<<ans<<'\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...