Submission #211787

#TimeUsernameProblemLanguageResultExecution timeMemory
211787skytectFoehn Phenomena (JOI17_foehn_phenomena)C++17
100 / 100
136 ms11640 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long ll n, q, s, t, d[200001], up = 0, down = 0; void update(ll p, ll x) { if (p < 1 or p > n) return; if (d[p] > 0) up -= d[p]; else down += d[p]; d[p] += x; if (d[p] > 0) up += d[p]; else down -= d[p]; } int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n >> q >> s >> t; ll last = 0; for (ll i = 0; i <= n; ++i) { cin >> d[i]; d[i] -= last; if (d[i] > 0) up += d[i]; else down -= d[i]; last += d[i]; } for (ll i = 0; i < q; ++i) { ll l, r, x; cin >> l >> r >> x; update(l, x); update(r + 1, -x); cout << t * down - s * up << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...