Submission #749915

#TimeUsernameProblemLanguageResultExecution timeMemory
749915PringFoehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
122 ms7288 KiB
#include <bits/stdc++.h> using namespace std; #define int long long typedef pair<int, int> pii; #define endl '\n' const int MXN = 200005; int n, q, s, t, a[MXN], d[MXN], ans; int l, r, x; inline int f(int id) { if (d[id] >= 0) return d[id] * s; else return d[id] * t; } int32_t main() { cin.tie(0) -> sync_with_stdio(false); cout.tie(0); cin >> n >> q >> s >> t; for (int i = 0; i <= n; i++) { cin >> a[i]; } for (int i = 0; i < n; i++) { d[i] = a[i + 1] - a[i]; ans -= f(i); } // for (int i = 0; i < n; i++) cout << d[i] << ' '; // cout << endl; // cout << ans << endl; while (q--) { cin >> l >> r >> x; l--; ans += f(l); if (r < n) ans += f(r); d[l] += x; d[r] -= x; ans -= f(l); if (r < n) ans -= f(r); // for (int i = 0; i < n; i++) cout << d[i] << ' '; // cout << endl; cout << ans << endl; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...