Loading problem...
You are given a boarding queue table named Queue.
Table columns:
Operational rules:
Task:
Output requirements:
Supported submission environments:
Queue:
| person_id | person_name | weight | turn |
|-----------|-------------|--------|------|
| 5 | Alice | 250 | 1 |
| 4 | Bob | 175 | 5 |
| 3 | Alex | 350 | 2 |
| 6 | John Cena | 400 | 3 |
| 1 | Winston | 500 | 6 |
| 2 | Marie | 200 | 4 |[
{"person_name":"John Cena"}
]Boarding by turn gives cumulative weights 250, 600, 1000, then 1200. The turn-3 passenger is the last one within capacity.
Queue:
| person_id | person_name | weight | turn |
|-----------|-------------|--------|------|
| 11 | Nora Stone | 400 | 1 |
| 12 | Ravi Hale | 200 | 2 |
| 13 | Lea Kim | 300 | 3 |
| 14 | Omar Diaz | 100 | 4 |
| 15 | Tara Bloom | 50 | 5 |[
{"person_name":"Omar Diaz"}
]The first four passengers sum to exactly 1000, so turn 4 is still valid. Turn 5 would exceed the cap.
Queue:
| person_id | person_name | weight | turn |
|-----------|-------------|--------|------|
| 21 | Mira Cole | 120 | 1 |
| 22 | Jian Park | 150 | 2 |
| 23 | Ivan Reed | 170 | 3 |
| 24 | Zoe Lane | 190 | 4 |[
{"person_name":"Zoe Lane"}
]Total cumulative weight is 630, so everyone boards and the final turn in the queue is the answer.
Constraints