제출 #944901

#제출 시각아이디문제언어결과실행 시간메모리
944901NeltFoehn Phenomena (JOI17_foehn_phenomena)C++17
100 / 100
92 ms13044 KiB
#include <bits/stdc++.h> #define ll long long #define endl "\n" using namespace std; void solve() { ll n, q, s, t; cin >> n >> q >> s >> t; ll a[n + 1], b[n]; for (ll &i : a) cin >> i; ll ans = 0; for (ll i = 1; i <= n; i++) b[i] = a[i] - a[i - 1], ans -= (b[i] < 0 ? b[i] * t : b[i] * s); while (q--) { ll l, r, x; cin >> l >> r >> x; ans += (b[l] < 0 ? b[l] * t : b[l] * s); if (r + 1 <= n) ans += (b[r + 1] < 0 ? b[r + 1] * t : b[r + 1] * s); b[l] += x; if (r + 1 <= n) b[r + 1] -= x; ans -= (b[l] < 0 ? b[l] * t : b[l] * s); if (r + 1 <= n) ans -= (b[r + 1] < 0 ? b[r + 1] * t : b[r + 1] * s); cout << ans << endl; } } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); ll t = 1; // precomp(); // cin >> t; for (ll i = 1; i <= t; i++) solve(); cerr << "\nTime elapsed: " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...