WeworkOA #2
Shopping and Billing
Estimated MediumStatement and editorial — judging is being prepared
Topics (AI-labelled)SimulationStacks & Heaps
In a shop with N counters, M people arrive for billing at different times denoted as time[i]. Each person selects the counter with the shortest queue, based on the number of people already present. If a counter is empty, the person gets immediate billing, otherwise, they join the queue.
For every person, output the time when they finish billing and leave the counter.
Notes
- It takes 1 unit of time for the counter to process a person's bill.
- The counter processes the next person immediately after the current person leaves. Input/Output
- The first line contains
Ndenoting the number of counters. - The second line contains
Mdenoting the number of persons. - The third line contains an array
time, indicating the entry time of the people.
Editorial
Loading solution…