제출 #298602

#제출 시각아이디문제언어결과실행 시간메모리
298602reymontada61Foehn Phenomena (JOI17_foehn_phenomena)C++14
30 / 100
1002 ms11468 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int MXN = 200005; int n, q, s, t; int diff[MXN]; // diff[i] -> i-1 to i 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() { 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...