제출 #538313

#제출 시각아이디문제언어결과실행 시간메모리
538313status_codingFoehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
113 ms11580 KiB
#include <iostream> using namespace std; long long n,q,s,t; long long ans; long long a[200005]; void add(int i) { if(i > n) return; if(a[i] > 0) ans -= a[i]*s; else ans -= a[i]*t; } void del(int i) { if(i > n) return; if(a[i] > 0) ans += a[i]*s; else ans += a[i]*t; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin>>n>>q>>s>>t; cin>>a[0]; for(int i=1;i<=n;i++) cin>>a[i]; for(int i=n;i>=1;i--) { a[i]-=a[i-1]; add(i); } //cout<<ans<<'\n'; while(q) { q--; int l, r, x; cin>>l>>r>>x; del(l); del(r+1); a[l]+=x; a[r+1]-=x; add(l); add(r+1); cout<<ans<<'\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...