제출 #1158412

#제출 시각아이디문제언어결과실행 시간메모리
1158412crispxxFoehn Phenomena (JOI17_foehn_phenomena)C++20
0 / 100
74 ms4680 KiB
#include <bits/stdc++.h> using namespace std; #define nl '\n' struct BIT { int n; vector<int> bit; BIT(int n): n(n), bit(n + 1) {} void update(int i, int x) { for(; i <= n; i += i & -i) bit[i] += x; } int get(int i) { int res = 0; for(; i >= 1; i -= i & -i) res += bit[i]; return res; } void set(int i, int x) { update(i, x - (get(i) - get(i - 1))); } }; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, q, s, t; cin >> n >> q >> s >> t; vector<int> a(n + 1), b(n + 1); for(auto &x : a) cin >> x; BIT fn(n); for(int i = 1; i <= n; i++) { b[i] = a[i - 1] - a[i]; if(b[i] > 0) fn.set(i, b[i] * t); if(b[i] < 0) fn.set(i, b[i] * s); } while(q--) { int l, r, x; cin >> l >> r >> x; b[l] += -x; if(b[l] > 0) fn.set(l, b[l] * t); if(b[l] < 0) fn.set(l, b[l] * s); r++; if(r <= n) { b[r] += x; if(b[r] > 0) fn.set(r, b[r] * t); if(b[r] < 0) fn.set(r, b[r] * s); } cout << fn.get(n) << nl; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...