Loading problem...
An airline analytics team needs a compact load report for every scheduled flight.
Table: Flights
Table: Passengers
Seat allocation model:
Task: Return one row per flight with booked and waitlist totals.
Output requirements:
Supported submission environments:
Flights:
| flight_id | capacity |
|-----------|----------|
| 1 | 2 |
| 2 | 2 |
| 3 | 1 |
Passengers:
| passenger_id | flight_id |
|--------------|-----------|
| 101 | 1 |
| 102 | 1 |
| 103 | 1 |
| 104 | 2 |
| 105 | 2 |
| 106 | 3 |
| 107 | 3 |[
{"flight_id":1,"booked_cnt":2,"waitlist_cnt":1},
{"flight_id":2,"booked_cnt":2,"waitlist_cnt":0},
{"flight_id":3,"booked_cnt":1,"waitlist_cnt":1}
]Flight 1 has three requests for two seats, so one request is waitlisted. Flight 2 exactly fits capacity. Flight 3 has one extra request beyond capacity.
Flights:
| flight_id | capacity |
|-----------|----------|
| 10 | 3 |
| 11 | 1 |
| 12 | 4 |
Passengers:
| passenger_id | flight_id |
|--------------|-----------|
| 201 | 10 |
| 202 | 10 |
| 203 | 11 |[
{"flight_id":10,"booked_cnt":2,"waitlist_cnt":0},
{"flight_id":11,"booked_cnt":1,"waitlist_cnt":0},
{"flight_id":12,"booked_cnt":0,"waitlist_cnt":0}
]Flight 12 appears even without bookings. booked_cnt and waitlist_cnt are both 0 for flights with no passenger requests.
Flights:
| flight_id | capacity |
|-----------|----------|
| 50 | 1 |
Passengers:
| passenger_id | flight_id |
|--------------|-----------|
| 901 | 50 |
| 902 | 50 |
| 903 | 50 |
| 904 | 50 |[
{"flight_id":50,"booked_cnt":1,"waitlist_cnt":3}
]Only one seat is available, so one booking is confirmed and the remaining three requests are waitlisted.
Constraints