Submission #771826

#TimeUsernameProblemLanguageResultExecution timeMemory
771826kirakaminski968Foehn Phenomena (JOI17_foehn_phenomena)C++17
100 / 100
107 ms13120 KiB
#include <bits/stdc++.h> #define ll long long using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int N,Q; ll S,T; cin >> N >> Q >> S >> T; vector<ll> arr(N+1); for(auto &x : arr) cin >> x; vector<ll> wind(N); for(int i = 0;i<N;++i) wind[i] = arr[i]-arr[i+1]; auto upd = [&](int ind){ if(wind[ind] < 0) return S*wind[ind]; else return T*wind[ind]; }; ll ans = 0; for(int i = 0;i<N;++i) ans += upd(i); while(Q--){ int l,r; ll val; cin >> l >> r >> val; ans -= upd(l-1); wind[l-1] -= val; ans += upd(l-1); if(r < N){ ans -= upd(r); wind[r] += val; ans += upd(r); } cout << ans << "\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...