Submission #936662

#TimeUsernameProblemLanguageResultExecution timeMemory
936662kitlixFoehn Phenomena (JOI17_foehn_phenomena)C++17
100 / 100
91 ms8784 KiB
#include <bits/stdc++.h> #define int long long using namespace std; signed main() { ios_base::sync_with_stdio(0), cin.tie(0); int n, q, s, t; cin >> n >> q >> s >> t; vector<int> diff(n); int prv = 0; cin >> prv; int curans = 0; auto conv = [&](int x) { if (x < 0) return -x * t; return -x * s; }; for (int i = 0; i < n; ++i) { int cur; cin >> cur; diff[i] = cur - prv; curans += conv(diff[i]); prv = cur; } while (q--) { int li, ri, xi; cin >> li >> ri >> xi; curans -= conv(diff[li - 1]); diff[li - 1] += xi; curans += conv(diff[li - 1]); if (ri != n) { curans -= conv(diff[ri]); diff[ri] -= xi; curans += conv(diff[ri]); } cout << curans << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...