제출 #755495

#제출 시각아이디문제언어결과실행 시간메모리
755495PixelCatFoehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
160 ms11532 KiB
#include <bits/stdc++.h> #define For(i, a, b) for(int i = a; i <= b; i++) #define Forr(i, a, b) for(int i = a; i >= b; i--) #define F first #define S second #define all(x) x.begin(), x.end() #define sz(x) ((int)x.size()) #define eb emplace_back #define int LL using namespace std; using LL = long long; using pii = pair<int, int>; const int MAXN = 200020; int a[MAXN]; int32_t main() { ios::sync_with_stdio(false); cin.tie(0); // =^-w-^= int n, q, s, t; cin >> n >> q >> s >> t; For(i, 0, n) cin >> a[i]; Forr(i, n, 1) a[i] -= a[i - 1]; auto cost = [&](int x) { x = a[x]; if(x >= 0) return -(x * s); return -(x * t); }; int ans = 0; For(i, 1, n) ans += cost(i); while(q--) { int l, r, x; cin >> l >> r >> x; r++; ans -= cost(l); a[l] += x; ans += cost(l); if(r <= n) { ans -= cost(r); a[r] -= x; ans += cost(r); } cout << ans << "\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...