제출 #537752

#제출 시각아이디문제언어결과실행 시간메모리
537752truc12a2cvpFoehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
120 ms12264 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> II; const int N = 2e5 + 5, logN = 20; const int MOD = 1e9 + 7; const ll INF = 1e9; int n, q, s, t, a[N]; ll ans = 0, dif[N]; void update(int i, ll val){ if(dif[i] > 0) ans += dif[i] * 1ll * s; else ans += dif[i] * 1ll * t; dif[i] = val; if(dif[i] > 0) ans -= dif[i] * 1ll * s; else ans -= dif[i] * 1ll * t; } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cin >> n >> q >> s >> t; for(int i = 0; i <= n; i ++) cin >> a[i]; for(int i = 1; i <= n; i ++){ update(i, a[i] - a[i - 1]); } while(q --){ int l, r, x; cin >> l >> r >> x; update(l, dif[l] + x); if(r + 1 <= n) update(r + 1, dif[r + 1] - x); cout << ans << "\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...