← 返回 capitalone 的题目列表Queue Check-in Simulation with Capacity Limit
类型:online_judge
Problem
There is a single check-in line. You are given an integer array arrivalTimes where arrivalTimes[i] is the time when person i arrives at the end of the line.
Rules:
Only one person is processed at a time.
The person at the front takes 30 seconds to check in.
When a person arrives, if the number of people currently waiting/being served in the system is greater than 10, that person leaves immediately and will not check in.
Return an array result:
If person i is served, result[i] is the time they start service.
Otherwise, result[i] = null.
Assume arrivalTimes is non-decreasing; ties are enqueued in input order.
Input
Integer array arrivalTimes
Output
Array result (each entry is an integer or null)
Constraints (suggested)
1 <= len(arrivalTimes) <= 2e5
0 <= arrivalTimes[i] <= 1e9
Examples
arrival=[0,0,0] → result=[0,30,60]
arrival=[0,10,20] → result=[0,30,60]
arrival=[0,100] → result=[0,100]
12 people arrive at time 0 → first 11 served, 12th leaves
arrival=[0,15,15,16] → result=[0,30,60,90]
Example
Input
3
0 0 0
Output
0 30 60