제출 #129293

#제출 시각아이디문제언어결과실행 시간메모리
129293nhimnam120Foehn Phenomena (JOI17_foehn_phenomena)C++14
0 / 100
695 ms5508 KiB
#include<bits/stdc++.h> using namespace std; const long long N=2e5+5; long long alt[N]; long long diff[N]; long long n,q,s,t; signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> q >> s >> t; long long ans=0; for(int i=0;i<=n;i++){ cin >> alt[i]; if(i>=1){ diff[i] = alt[i] - alt[i-1]; if(diff[i]>0){ ans = ans - diff[i]*s; } else{ ans = ans - diff[i]*t; } } } while(q--){ long long l, r, x; cin >> l >> r >> x; if(diff[l]>0){ ans = ans + diff[l]*s; } else{ ans = ans + diff[l]*t; } if(diff[r+1]>0){ ans = ans + diff[r+1]*s; } else{ ans = ans + diff[r+1]*t; } diff[l]+=x; diff[r+1]+=x; if(diff[l]>0){ ans = ans - diff[l]*s; } else{ ans = ans - diff[l]*t; } if(diff[r+1]>0){ ans = ans - diff[r+1]*s; } else{ ans = ans - diff[r+1]*t; } cout << ans<<endl; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...