Submission #877448

#TimeUsernameProblemLanguageResultExecution timeMemory
877448Beerus13Foehn Phenomena (JOI17_foehn_phenomena)C++14
0 / 100
74 ms3368 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; int n, q, s, t, ans = 0; int 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...