제출 #160488

#제출 시각아이디문제언어결과실행 시간메모리
160488jhnah917Foehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
172 ms13304 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll n, q, S, T, ans; vector<ll> input, v; void query(int x, ll val){ if(v[x] > 0) ans += v[x] * S; else ans += v[x] * T; // cout << ans << " "; v[x] += val; if(v[x] > 0) ans -= v[x] * S; else ans -= v[x] * T; // cout << ans << "\n"; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> q >> S >> T; input.resize(n+1); v.resize(n+1); for(int i=0; i<=n; i++) cin >> input[i]; for(int i=1; i<=n; i++) query(i, input[i] - input[i-1]); while(q--){ ll s, e, x; cin >> s >> e >> x; query(s, x); if(e < n) query(e+1, -x); cout << ans << "\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...