Submission #535368

#TimeUsernameProblemLanguageResultExecution timeMemory
535368amunduzbaevFoehn Phenomena (JOI17_foehn_phenomena)C++17
100 / 100
417 ms13044 KiB
#include "bits/stdc++.h" using namespace std; #define ar array #define int 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; int res = 0; auto add = [&](int i, int f){ if(i>n) return; if(d[i]>0) res-=s*d[i]*f; else res-=t*d[i]*f; }; for(int i=0;i<=n;i++){ cin>>a[i]; if(i) d[i] = a[i] - a[i-1]; add(i, 1); } while(q--){ 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<<endl; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...