Submission #877450

#TimeUsernameProblemLanguageResultExecution timeMemory
877450Beerus13Foehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
84 ms11604 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pii pair<ll, int> #define fi first #define se second const int N = 2e5 + 5; ll n, q, s, t, ans = 0; ll kc[N]; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> q >> s >> t; int pre_val; for(int i = 0; i <= n; ++i) { int x; cin >> x; if(i) { kc[i] = pre_val - x; if(kc[i] >= 0) ans += t * kc[i]; else ans += s * kc[i]; } pre_val = x; } while(q--) { int l, r, x; cin >> l >> r >> x; if(kc[l] >= 0) ans -= kc[l] * t; else ans -= kc[l] * s; kc[l] -= x; if(kc[l] >= 0) ans += kc[l] * t; else ans += kc[l] * s; if(r < n) { if(kc[r + 1] >= 0) ans -= kc[r + 1] * t; else ans -= kc[r + 1] * s; kc[r + 1] += x; if(kc[r + 1] >= 0) ans += kc[r + 1] * t; else ans += kc[r + 1] * s; } cout << ans << '\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...