Submission #51463

#TimeUsernameProblemLanguageResultExecution timeMemory
51463combi2k2Foehn Phenomena (JOI17_foehn_phenomena)C++14
0 / 100
131 ms3372 KiB
#include<bits/stdc++.h> using namespace std; 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; } int 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...