Submission #1116350

#TimeUsernameProblemLanguageResultExecution timeMemory
1116350staszic_ojuzFoehn Phenomena (JOI17_foehn_phenomena)C++17
0 / 100
67 ms4292 KiB
#include <iostream> #include <vector> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int64_t n,q,s,t,akt,pop,szt=0; cin >> n >> q >> s >> t; vector<int64_t> zmtp; cin >> pop; for (int i=0; i<n; i++){ if (i>0) pop=akt; cin >> akt; if (akt>pop) zmtp.push_back((pop-akt)*s); else zmtp.push_back((pop-akt)*t); szt+=zmtp[i]; } //for (int i=0; i<n; i++) cout << zmtp[i] << ' '; //cout << '\n'; for (int i=0; i<q; i++){ int64_t l,r,x; cin >> l >> r >> x; l--; r--; int64_t aktl=zmtp[l]; if (zmtp[l]>0 and zmtp[l]>=x*t) zmtp[l]-=x*t; else if (zmtp[l]>0){ x-=zmtp[l]/t; zmtp[l]=-x*s; } else if (zmtp[l]-x*s<=0) zmtp[l]-=x*s; else{ x-=zmtp[l]/s; zmtp[l]=-x*t; //cout << 'a'; } if (r+1<n){ int64_t aktr=zmtp[r+1]; if (zmtp[r+1]>0 and zmtp[r+1]>=-x*t) zmtp[r+1]+=x*t; else if (zmtp[r+1]>0){ x+=zmtp[r+1]/t; zmtp[r+1]=x*s; } else if (zmtp[r+1]+x*s<=0) zmtp[r+1]+=x*s; else{ x+=zmtp[r+1]/s; zmtp[r+1]=x*t; } szt+=zmtp[r+1]-aktr; //cout << zmtp[r+1] << ' ' << aktr << ' ' << zmtp[r+1]-aktr << ' '; } szt+=zmtp[l]-aktl; //cout << zmtp[l] << ' ' << aktl << ' ' << zmtp[l]-aktl << '\n'; //for (int i=0; i<n; i++) cout << zmtp[i] << ' '; //cout << '\n'; cout << szt << '\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...