Submission #867658

#TimeUsernameProblemLanguageResultExecution timeMemory
867658MongHwaFoehn Phenomena (JOI17_foehn_phenomena)C++17
100 / 100
96 ms13244 KiB
#include <iostream> using namespace std; #define ll long long ll arr[200001], diff[200001]; int main() { ios::sync_with_stdio(0); cin.tie(0); int n, q; ll s, t; cin >> n >> q >> s >> t; for(int i = 0; i <= n; i++) cin >> arr[i]; ll neg = 0, pos = 0; for(int i = 0; i < n; i++) { diff[i] = arr[i]-arr[i+1]; if(diff[i] < 0) neg -= diff[i]; else pos += diff[i]; } while(q--) { int l, r; ll d; cin >> l >> r >> d; if(diff[l-1] < 0) neg += diff[l-1]; else pos -= diff[l-1]; if(r < n && diff[r] < 0) neg += diff[r]; else if(r < n) pos -= diff[r]; diff[l-1] -= d; diff[r] += d; if(diff[l-1] < 0) neg -= diff[l-1]; else pos += diff[l-1]; if(r < n && diff[r] < 0) neg -= diff[r]; else if(r < n) pos += diff[r]; cout << -neg*s + pos*t << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...