Submission #1058413

#TimeUsernameProblemLanguageResultExecution timeMemory
1058413SzymonKrzywdaBikeparking (EGOI24_bikeparking)C++17
25 / 100
67 ms2764 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> tier(n); vector<int> lvl(n); for (int i=0; i<n; i++) cin >> tier[i]; for (int i=0; i<n; i++) cin >> lvl[i]; int akt_wsk=n-1; int wynik = 0; for (int i=n-1; i>=0; i--){ while (akt_wsk >= 0 && tier[akt_wsk]==0) akt_wsk--; while (akt_wsk>=0 && lvl[i]>0){ while (akt_wsk>=0 && akt_wsk>=i) akt_wsk--; if (akt_wsk>=i) break; int mini = min(tier[akt_wsk],lvl[i]); tier[akt_wsk]-=mini; lvl[i]-=mini; wynik+=mini; while (akt_wsk >= 0 && tier[akt_wsk]==0) akt_wsk--; } } akt_wsk=n-1; for (int i=0; i<n; i++){ if (lvl[i]>0){ int mini = min(tier[i],lvl[i]); tier[i] -= mini; lvl[i] -= mini; while (lvl[i]>0){ while (akt_wsk >= 0 && tier[akt_wsk]==0) akt_wsk--; int mini = min(tier[akt_wsk],lvl[i]); tier[i] -= mini; lvl[i] -= mini; wynik-=mini; } } } cout << wynik << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...