Submission #1017918

#TimeUsernameProblemLanguageResultExecution timeMemory
1017918vjudge1Foehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
81 ms7252 KiB
#include <bits/stdc++.h> #define int long long using namespace std; #define boost ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); const int N = 1e6 + 12, mod = 1e16 + 7; signed main () { boost int n, q, s, t; cin >> n >> q >> s >> t; vector<int>v(n + 1); for(int i = 0; i <= n; ++i){ cin >> v[i]; } vector<int>d(n + 1); int ans = 0; for(int i = 1; i <= n ; ++i){ d[i] = v[i] - v[i - 1]; if(d[i] > 0){ ans -= d[i] * s; } else { ans -= d[i] * t; } } while(q--){ int l, r, x; cin >> l >> r >> x; if(d[l] > 0){ ans += d[l] * s; } else { ans += d[l] * t; } if(r + 1 <= n){ if(d[r + 1] > 0){ ans += d[r + 1] * s; } else { ans += d[r + 1] * t; } } d[l] = d[l] + x; if(r + 1 <= n){ d[r + 1] = d[r + 1] - x; } if(d[l] > 0){ ans -= d[l] * s; } else { ans -= d[l] * t; } if(r + 1 <= n){ if(d[r + 1] > 0){ ans -= d[r + 1] * s; } else { ans -= d[r + 1] * t; } } cout << ans << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...