#K10071. Manage Table Reservations
Manage Table Reservations
Manage Table Reservations
In this problem, you are given a set of tables, each with a unique identifier and a capacity, along with their existing reservations. Each reservation is represented by a time slot and a number of guests. You are then given several new reservation attempts. For each attempt, check if the sum of the already reserved guests and the new guests at the same time slot does not exceed the table's capacity. Formally, given a table with capacity (C), an existing reservation of (G) guests at time (t), and a new request of (N) guests at time (t), the reservation is accepted if and only if (G + N \leq C). If the table does not exist or the condition is not met, the reservation is rejected.
inputFormat
The input is provided via standard input (stdin) with the following format:
- The first line contains an integer (T) representing the number of tables.
- The next (T) groups define each table:
- The first line of each group contains the table identifier (a string), the table capacity (an integer), and an integer (R_t) indicating the number of existing reservations for that table.
- The following (R_t) lines each contain two integers: the time slot and the number of guests for that reservation.
- After all table information, there is a line containing an integer (R) which represents the number of new reservation attempts.
- The next (R) lines each contain a reservation attempt with three values: the table identifier (a string), the time slot (an integer), and the number of guests (an integer).
outputFormat
For each reservation attempt, output a single line containing either "Accepted" or "Rejected" based on whether the reservation can be accommodated.## sample
2
Table1 4 2
1200 4
1930 2
Table2 2 1
1800 2
3
Table1 1200 2
Table2 1700 2
Table2 1800 1
Rejected
Accepted
Rejected
</p>