Submission #1116539

#TimeUsernameProblemLanguageResultExecution timeMemory
1116539staszic_ojuzFoehn Phenomena (JOI17_foehn_phenomena)C++17
0 / 100
78 ms9888 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){ if (x>0) zmtp[l]-=x*s; else zmtp[l]-=x*t; } else 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 (aktr==0){ if (x>0) zmtp[r+1]+=x*t; else zmtp[r+1]+=x*s; } if (aktr<0 and aktr+x*s<=0) zmtp[r+1]+=x*s; else if (aktr<0){ x+=aktr/s; zmtp[r+1]=x*t; } else if (aktr+x*t>=0) zmtp[r+1]+=x*t; else{ x-=zmtp[r+1]/t; zmtp[r+1]=x*s; } szt+=zmtp[r+1]-aktr; //cout << zmtp[r+1] << ' ' << aktr << ' ' << szt << '\n'; //cout << zmtp[r+1] << ' ' << aktr << ' ' << zmtp[r+1]-aktr << ' '; } szt+=zmtp[l]-aktl; //cout << zmtp[l] << ' ' << aktl << ' ' << zmtp[l]-aktl << '\n'; //for (int j=0; j<n; j++) cout << zmtp[j] << ' '; //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...