Submission #535347

#TimeUsernameProblemLanguageResultExecution timeMemory
535347amunduzbaevFoehn Phenomena (JOI17_foehn_phenomena)C++17
0 / 100
114 ms3884 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; auto add = [&](int i, int f){ if(i > n) return; if(d[i] > 0) res -= d[i] * s * f; else res -= d[i] * t * f; }; for(int i=1;i<=n;i++){ d[i] = a[i] - a[i-1]; add(i, 1); } for(int f=0;f<q;f++){ int l, r, x; cin>>l>>r>>x; add(l, -1), add(r+1, -1); d[l] += x, d[r + 1] -= x; add(l, 1), add(r+1, 1); cout<<res<<"\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...