Submission #1267348

#TimeUsernameProblemLanguageResultExecution timeMemory
1267348jj_masterFoehn Phenomena (JOI17_foehn_phenomena)C++20
30 / 100
1096 ms2496 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define pb push_back #define eb emplace_back #define fi first #define se second int compute_cost(int diff, int s, int t) { if (diff > 0) return -diff * s; else return -diff * t; } void sol() { int n, q, s, t; cin >> n >> q >> s >> t; vector<int> a; int x; for(int i = 0; i <= n; i++) { cin >> x; a.pb(x); } int total = 0; for (int i = 0; i < n; i++) { int diff = a[i + 1] - a[i]; total += compute_cost(diff, s, t); } while (q--) { int l, r, z; cin >> l >> r >> z; if (l > 0) { int before = a[l] - a[l - 1]; int after = (a[l] + z) - a[l - 1]; total -= compute_cost(before, s, t); total += compute_cost(after, s, t); } if (r < n) { int before = a[r + 1] - a[r]; int after = a[r + 1] - (a[r] + z); total -= compute_cost(before, s, t); total += compute_cost(after, s, t); } for (int i = l; i <= r; i++) { a[i] += z; } cout << total << '\n'; } } int32_t main() { ios::sync_with_stdio(false); cin.tie(0); sol(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...