Capital OneOA #16
Queue Check-in Simulation with Capacity Limit
Estimated MediumJudge-ready
Topics (AI-labelled)SimulationStacks & Heaps
A single service desk serves people first come, first served, and each person takes 30 seconds. On arrival, if the number of people currently in the system is greater than 10, the person leaves immediately; otherwise they are admitted and their service start time is output. Output null for anyone not admitted.
Input
The first line contains n (this site adopts the source's suggested range 1≤n≤200000), and the second line contains n non-decreasing arrival times arrival[i] (this site adopts the source's suggested range 0≤arrival[i]≤10^9). People arriving at the same time join the queue in input order.
Output
Output each person's service start time or null in input order, separated by spaces. The rules in the statement imply that the system admits at most 11 people; at the exact moment someone finishes, the finished person leaves first.
Example 1
Input:
3
0 0 0
Output:
0 30 60
Example 2
Input:
3
0 10 20
Output:
0 30 60
Example 3
Input:
2
0 100
Output:
0 100
Editorial
Loading solution…