Submission #534335

#TimeUsernameProblemLanguageResultExecution timeMemory
534335LittleOrangeFoehn Phenomena (JOI17_foehn_phenomena)C++17
100 / 100
144 ms13148 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; int main(){ ios::sync_with_stdio(0);cin.tie(0); ll n,q,s,t; cin >> n >> q >> s >> t; vector<ll> a(n+1,0),d(n+1,0); for (int i = 0;i<=n;i++){ cin >> a[i]; if (i) d[i] = a[i]-a[i-1]; } auto f = [&s,&t](ll i){return i>0?i*s:i*t;}; ll ans = 0; for (int i = 1;i<=n;i++){ ans -= f(d[i]); } while (q--){ ll l,r,x; cin >> l >> r >> x; ans += f(d[l]); d[l]+=x; ans -= f(d[l]); if (r<n){ ans+=f(d[r+1]); d[r+1]-=x; ans-=f(d[r+1]); } cout << ans << "\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...