Submission #396642

#TimeUsernameProblemLanguageResultExecution timeMemory
396642timmyfengFoehn Phenomena (JOI17_foehn_phenomena)C++17
100 / 100
149 ms6772 KiB
#include <bits/stdc++.h> using namespace std; const int N = 200001; long long diff[N]; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n, q, s, t; cin >> n >> q >> s >> t; for (int i = 0; i <= n; ++i) { cin >> diff[i]; } adjacent_difference(diff, diff + n + 1, diff); long long wind = 0; for (int i = 0; i <= n; ++i) { wind -= (diff[i] < 0 ? t : s) * diff[i]; } while (q--) { int l, r, x; cin >> l >> r >> x; wind += (diff[l] < 0 ? t : s) * diff[l]; diff[l] += x; wind -= (diff[l] < 0 ? t : s) * diff[l]; if (r < n) { wind += (diff[r + 1] < 0 ? t : s) * diff[r + 1]; diff[r + 1] -= x; wind -= (diff[r + 1] < 0 ? t : s) * diff[r + 1]; } cout << wind << "\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...