Submission #546093

#TimeUsernameProblemLanguageResultExecution timeMemory
546093HanksburgerFoehn Phenomena (JOI17_foehn_phenomena)C++17
100 / 100
105 ms11468 KiB
#include <bits/stdc++.h> using namespace std; long long a[200005], diff[200005]; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n, q, s, t, pre, ans=0; cin >> n >> q >> s >> t >> pre; for (long long i=1; i<=n; i++) { long long x; cin >> x; diff[i]=x-pre; pre=x; if (diff[i]>=0) ans-=diff[i]*s; else ans-=diff[i]*t; } for (long long i=1; i<=q; i++) { long long l, r, x; cin >> l >> r >> x; if (diff[l]>=0) ans+=diff[l]*s; else ans+=diff[l]*t; diff[l]+=x; if (diff[l]>=0) ans-=diff[l]*s; else ans-=diff[l]*t; if (r<n) { if (diff[r+1]>=0) ans+=diff[r+1]*s; else ans+=diff[r+1]*t; diff[r+1]-=x; if (diff[r+1]>=0) ans-=diff[r+1]*s; else ans-=diff[r+1]*t; } cout << ans << '\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...