제출 #896382

#제출 시각아이디문제언어결과실행 시간메모리
896382goodspeed0208Foehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
487 ms13180 KiB
#include<iostream> #include<vector> #include<algorithm> #include<set> #include<map> #include<utility> #define int long long #define INF 1000000000000000000 using namespace std; signed main() { int n, q, s, t; cin >> n >> q >> s >> t; vector<int>v(n+5), dif(n+5); for (int i = 0 ; i <= n ; i++) cin >> v[i]; int ans = 0; for (int i = 0 ; i < n ; i++) { dif[i] = v[i+1] - v[i]; if (dif[i] > 0) ans -= s * dif[i]; else ans += t * (-dif[i]); } //cout << ans << "\n"; int l, r, x; while (q--) { cin >> l >> r >> x; if (dif[l-1] > 0) ans += s * dif[l-1]; else ans -= t * -(dif[l-1]); dif[l-1] += x; if (dif[l-1] > 0) ans -= s * dif[l-1]; else ans += t * -(dif[l-1]); if (r != n) { if (dif[r] > 0) ans += s * dif[r]; else ans -= t * -(dif[r]); dif[r] -= x; if (dif[r] > 0) ans -= s * dif[r]; else ans += t * -(dif[r]); } cout << ans << "\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...