Submission #824047

#TimeUsernameProblemLanguageResultExecution timeMemory
82404712345678Foehn Phenomena (JOI17_foehn_phenomena)C++17
100 / 100
99 ms13200 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long const int nx=2e5+5; ll v[nx], d[nx], n, q, s, t, l, r, k, ans, tmp; int main() { cin.tie(NULL)->sync_with_stdio(false); cin>>n>>q>>s>>t>>tmp; for (int i=1; i<=n; i++) cin>>v[i], d[i]=v[i]-v[i-1]; for (int i=1; i<=n; i++) ans=(d[i]>0)?ans+d[i]*s:ans+d[i]*t; while (q--) { cin>>l>>r>>k; ans=(d[l]>0)?ans-d[l]*s:ans-d[l]*t; d[l]+=k; ans=(d[l]>0)?ans+d[l]*s:ans+d[l]*t; if (r==n) { cout<<-ans<<'\n'; continue; } ans=(d[r+1]>0)?ans-d[r+1]*s:ans-d[r+1]*t; d[r+1]-=k; ans=(d[r+1]>0)?ans+d[r+1]*s:ans+d[r+1]*t; cout<<-ans<<'\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...