ZipRecruiterOA #9
Exclusive Event Entry
Estimated MediumJudge-ready
Topics (AI-labelled)Simulation
Guests arrive in non-decreasing order. An ID check takes 300 seconds. The guest currently being checked is not counted in the waiting queue; if, on arrival, the number of waiting guests is already greater than 10, the guest leaves and their arrival time is output. If a guest arrives at the same moment a check finishes, the guests already waiting start their check first, and the new guest joins the end of the queue. Output each guest's completion time; for guests who leave, output their arrival time.
Input
The first line contains n (1..5000); the second line contains n non-decreasing non-negative integer arrival times (≤10^9).
Output
Output n space-separated integers in arrival order.
Example 1
Input:
4
4 400 450 500
Output:
304 700 1000 1300
Example 2
Input:
15
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Output:
301 601 901 1201 1501 1801 2101 2401 2701 3001 3301 3601 13 14 15
Example 3
Input:
3
0 1 300
Output:
300 600 900
Editorial
Loading solution…