Submission #288237

#TimeUsernameProblemLanguageResultExecution timeMemory
288237HabitusFoehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
576 ms11640 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int N = (int)2e5+99; ll diff[N], n, q, s, t; ll pov, nepov; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> n >> q >> s >> t; ll pret; cin >> pret; for(int i=1; i<=n; ++i) { ll tren; cin >> tren; diff[i]=tren-pret; pret=tren; if(diff[i]>0LL) pov+=diff[i]; else nepov-=diff[i]; } //cout << pov << ' ' << nepov << endl; while(q--) { ll pr, dr, tr; cin >> pr >> dr >> tr; bool biopov; ll stari; stari=diff[pr]; if(stari>0LL) biopov=true; else biopov=false; diff[pr]+=tr; if(diff[pr]>0LL && biopov) { pov-=stari-diff[pr]; } else if(diff[pr]>0LL && !biopov) { nepov+=stari; pov+=diff[pr]; } else if(biopov) { pov-=stari; nepov-=diff[pr]; } else { nepov+=stari-diff[pr]; } //cout << pov << ' ' << nepov << endl; if(dr!=n) { stari=diff[dr+1]; if(stari>0LL) biopov=true; else biopov=false; diff[dr+1]-=tr; if(diff[dr+1]>0LL && biopov) { pov-=stari-diff[dr+1]; } else if(diff[dr+1]>0LL && !biopov) { nepov+=stari; pov+=diff[dr+1]; } else if(biopov) { pov-=stari; nepov-=diff[dr+1]; } else { nepov+=stari-diff[dr+1]; } } //for(int i=1; i<=n; ++i) cout << diff[i] << ' '; cout << endl; //cout << pov << ' ' << nepov << endl; cout << -pov*s + nepov*t << endl; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...