Submission #51468

#TimeUsernameProblemLanguageResultExecution timeMemory
51468combi2k2Foehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
233 ms5972 KiB
#include<bits/stdc++.h> using namespace std; #define int long long const int N = 2e5 + 1; int a[N], n, q, s, t; int f(int x) { if(x < 0) return x * s; return x * t; } signed main(){ ios_base::sync_with_stdio(false); cin.tie(0); cin >> n >> q >> s >> t; int ans = 0; for(int i = 0 ; i <= n ; ++i) { cin >> a[i]; if(i) { a[i - 1] = a[i - 1] - a[i]; ans += f(a[i - 1]); } } while(q--) { int l, r, x; cin >> l >> r >> x; if(l > 0) { ans -= f(a[l - 1]); a[l - 1] -= x; ans += f(a[l - 1]); } if(r < n) { ans -= f(a[r]); a[r] += x; ans += f(a[r]); } cout << ans << "\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...