Submission #298603

#TimeUsernameProblemLanguageResultExecution timeMemory
298603reymontada61Foehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
584 ms13176 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int MXN = 200005; int n, q, s, t; int diff[MXN]; int height[MXN]; int temp; int get(int of) { if (of > 0) return -s * of; else return abs(t * of); } void upd(int pos, int by) { temp -= get(diff[pos]); diff[pos] += by; temp += get(diff[pos]); } signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> q >> s >> t; for (int i=0; i<=n; i++) { cin >> height[i]; } for (int i=1; i<=n; i++) { diff[i] = height[i] - height[i-1]; temp += get(diff[i]); } for (int i=0; i<q; i++) { int l, r, x; cin >> l >> r >> x; upd(l, x); if (r < n) upd(r+1, -x); cout << temp << endl; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...