Submission #1058317

#TimeUsernameProblemLanguageResultExecution timeMemory
1058317Szymon_PilipczukBikeparking (EGOI24_bikeparking)C++17
44 / 100
69 ms4436 KiB
#include <iostream> using namespace std; int main() { int n; cin>>n; int slots[n]; int people[n]; int population = 0; for(int i = 0;i<n;i++) { cin>>slots[i]; } for(int i = 0;i<n;i++) { cin>>people[i]; population+=people[i]; } int free = 0; int rating = 0; int u; for(int i = 0;i<n;i++) { u = min(free,people[i]); free-=u; people[i]-=u; population-=u; rating+=u; if(slots[i]>people[i]) { free+=slots[i]-people[i]; slots[i] = people[i]; } } free = 0; for(int i = 0;i<n;i++) { population -= people[i]; u = min(free,people[i]); free -=u; people[i]-=u; rating+=u; if(slots[i]>population) { free= population; rating -=max(people[i]-(slots[i]-population),0); } else { free+=slots[i]; rating-=people[i]; } } cout<<rating; }
#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...