Submission #1259482

#TimeUsernameProblemLanguageResultExecution timeMemory
1259482ngonamkhanhFoehn Phenomena (JOI17_foehn_phenomena)C++20
100 / 100
62 ms7256 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long ll n, q, s, t; ll l, r, x; ll a[200005]; ll d[200005]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> q >> s >> t; for (int i = 0; i <= n; i++) { cin >> a[i]; } ll kq = 0; for (int i = 1; i <= n; i++) { d[i] = a[i] - a[i - 1]; if (d[i] <= 0) { kq += -t * d[i]; } else { kq -= s * d[i]; } } for (int i = 1; i <= q; i++) { cin >> l >> r >> x; if (d[l] <= 0) { kq -= -t * d[l]; } else { kq += s * d[l]; } d[l] += x; if (d[l] <= 0) { kq += -t * d[l]; } else { kq -= s * d[l]; } if (r + 1 <= n) { if (d[r + 1] <= 0) { kq -= -t * d[r + 1]; } else { kq += s * d[r + 1]; } d[r + 1] -= x; if (d[r + 1] <= 0) { kq += -t * d[r + 1]; } else { kq -= s * d[r + 1]; } } cout << kq << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...