제출 #94515

#제출 시각아이디문제언어결과실행 시간메모리
94515fedoseevtimofeyFoehn Phenomena (JOI17_foehn_phenomena)C++14
30 / 100
120 ms10616 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.setf(ios::fixed); cout.precision(20); #ifdef LOCAL freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif int n, q, s, t; cin >> n >> q >> s >> t; vector <int> a(n + 1); for (int i = 0; i < n + 1; ++i) { cin >> a[i]; } vector <int> diff(n + 1); for (int i = 1; i <= n; ++i) diff[i] = a[i] - a[i - 1]; ll ans = 0; for (int i = 1; i <= n; ++i) { if (diff[i] > 0) ans -= (ll)(diff[i]) * s; else ans += (ll)(-diff[i]) * t; } for (int i = 0; i < q; ++i) { int l, r, x; cin >> l >> r >> x; if (diff[l] > 0) { ans += (ll)diff[l] * s; } else { ans -= (ll)-diff[l] * t; } diff[l] += x; if (diff[l] > 0) { ans -= (ll)diff[l] * s; } else { ans += (ll)-diff[l] * t; } if (r + 1 <= n) { if (diff[r + 1] > 0) { ans += (ll)diff[r + 1] * s; } else { ans -= (ll)-diff[r + 1] * t; } diff[r + 1] -= x; if (diff[r + 1] > 0) { ans -= (ll)diff[r + 1] * s; } else { ans += (ll)-diff[r + 1] * t; } } cout << ans << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...