#K68337. Restaurant Reservation System
Restaurant Reservation System
Restaurant Reservation System
You are a software developer tasked with implementing a reservation system for a popular restaurant. Each day, the restaurant receives a number of reservation requests, where each request consists of a party size and a desired reservation time. The restaurant has a limited number of tables, and each table can seat exactly 4 guests.
Your goal is to process the reservation requests in the order of increasing reservation time and assign tables to as many requests as possible. When a request is fulfilled, one table is consumed and the number of guests in the party is added to the total seated count. Only requests with a party size of at most 4 can be fulfilled. If no request is fulfilled on a given day, output a corresponding message.
Formally, for each day you are given:
- T — the number of available tables
- R — the number of reservation requests
- Followed by R lines, each with two integers S and t, where S is the party size and t is the reservation time.
Process the requests sorted by reservation time. For each day, if at least one reservation is fulfilled, output the number of fulfilled requests and the total number of guests seated; otherwise, output that no reservations were fulfilled.
Note: If a request's party size is more than 4, it cannot be fulfilled. Once a table is used, it cannot be reassigned to another request.
Constraints:
- 1 ≤ d ≤ 10 (number of days)
- 1 ≤ T ≤ 20 (number of tables)
- 0 ≤ R ≤ 50 (number of reservation requests; R can be 0)
- 1 ≤ S ≤ 4 (party size)
- 1 ≤ t ≤ 24 (reservation time)
inputFormat
The input is read from standard input (stdin) and has the following format:
d T1 R1 S1 t1 S2 t2 ... (R1 lines for day 1) T2 R2 S1 t1 S2 t2 ... (R2 lines for day 2) ... Td Rd S1 t1 S2 t2 ... (Rd lines for day d)
Where:
d
is the number of days.- For each day, the first line contains two integers:
T
(available tables) andR
(number of reservation requests). - Each of the following R lines contains two integers: the party size
S
and the reservation timet
.
outputFormat
The output should be written to standard output (stdout). For each day, output the following:
- If at least one reservation is fulfilled, output:
For Day #i: <number of fulfilled requests> Totally seated guests: <total number of guests>
- If no reservations are fulfilled, output:
For Day #i: No reservations fulfilled
Note that i
is the 1-indexed day number.
1
5 6
3 18
4 19
2 20
4 21
1 22
3 22
For Day #1:
5
Totally seated guests: 14
</p>