Submission #33255

#TimeUsernameProblemLanguageResultExecution timeMemory
33255minkankFoehn Phenomena (JOI17_foehn_phenomena)C++14
30 / 100
259 ms3576 KiB
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; int n, m, s, t; long long ans = 0, a[N]; int main() { cin >> n >> m >> t >> s; for(int i = 0; i <= n; ++i) cin >> a[i]; for(int i = n; i >= 1; --i) { a[i] -= a[i - 1]; if(a[i] > 0) ans -= a[i] * t; else ans += -a[i] * s; } for(int i = 0; i < m; ++i) { int l, r, x; cin >> l >> r >> x; if(a[l] > 0) ans += a[l] * t; else ans -= -a[l] * s; a[l] += x; if(a[l] > 0) ans -= a[l] * t; else ans += -a[l] * s; if(r != n) { if(a[r + 1] > 0) ans += a[r + 1] * t; else ans -= -a[r + 1] * s; a[r + 1] -= x; if(a[r + 1] > 0) ans -= a[r + 1] * t; else ans += -a[r + 1] * s; } cout << ans << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...