Submission #535346

#TimeUsernameProblemLanguageResultExecution timeMemory
535346amunduzbaevFoehn Phenomena (JOI17_foehn_phenomena)C++17
0 / 100
92 ms3828 KiB
#include "bits/stdc++.h" using namespace std; #define ar array #define long long const int N = 2e5 + 5; int a[N], d[N]; signed main(){ ios::sync_with_stdio(0); cin.tie(0); int n, q, s, t; cin>>n>>q>>s>>t; for(int i=0;i<=n;i++) cin>>a[i]; int res = 0; for(int i=1;i<=n;i++){ d[i] = a[i] - a[i-1]; if(d[i] > 0) res -= (d[i] * s); else res -= (d[i] * t); } auto upd = [&](int i, int x){ if(i > n) return; if(d[i] > 0) res += (d[i] * s); else res += (d[i] * t); d[i] += x; if(d[i] > 0) res -= (d[i] * s); else res -= (d[i] * t); }; while(q--){ int l, r, x; cin>>l>>r>>x; upd(l, x); upd(r + 1, -x); cout<<res<<"\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...