Submission #230022

#TimeUsernameProblemLanguageResultExecution timeMemory
230022nickmet2004Foehn Phenomena (JOI17_foehn_phenomena)C++11
100 / 100
521 ms11768 KiB
#include<bits/stdc++.h> typedef long long ll; using namespace std; const int N = 2e5 + 500; ll n , Q , S , T; ll d[N]; ll pos , neg , last; void upd(int p , ll X){ if(p > n) return; if(d[p] > 0) pos -= d[p]; else neg += d[p]; d[p] += X; if(d[p] > 0) pos += d[p]; else neg -= d[p]; } int main (){ ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> Q >> S >> T; for(int i = 0; i <= n; ++i){ cin >> d[i]; d[i] -= last; if(d[i] > 0) pos += d[i]; else neg -= d[i]; last += d[i]; } while(Q--){ int l , r; ll x; cin >> l >> r >> x; upd(l , x); upd(r + 1 , -x); cout << ll(neg*T - pos * S) << endl; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...