제출 #1051560

#제출 시각아이디문제언어결과실행 시간메모리
1051560alex_2008Foehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
357 ms7344 KiB
#include <iostream> #include <vector> #include <algorithm> #include <stack> using namespace std; typedef long long ll; const int N = 2e5 + 10; ll h[N], a[N]; int main() { ll n, q, s, t; cin >> n >> q >> s >> t; for (int i = 0; i <= n; i++) { cin >> h[i]; } ll cur_s = 0, cur_t = 0; for (int i = 1; i <= n; i++) { a[i] = h[i] - h[i - 1]; if (a[i] > 0) cur_s += a[i]; else cur_t += (-a[i]); } while (q--) { ll l, r, x; cin >> l >> r >> x; if (a[l] > 0) cur_s -= a[l]; else cur_t -= (-a[l]); a[l] += x; if (a[l] > 0) cur_s += a[l]; else cur_t += (-a[l]); if (r != n) { if (a[r + 1] > 0) cur_s -= a[r + 1]; else cur_t -= (-a[r + 1]); a[r + 1] -= x; if (a[r + 1] > 0) cur_s += a[r + 1]; else cur_t += (-a[r + 1]); } cout << cur_t * 1ll * t - cur_s * 1ll * s << "\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...