|
||||||||||||||||||||
Tables
Peter’s friend, Paul is the boss in a restaurant and he asked for Peter’s help in a troublesome matter! The restaurant’s online booking system has malfunctioned: some reservations were mistakenly booked which are impossible to satisfy. Your job is to filter out these from the bookings. In the restaurant there are tables, each of which has seats. The reservation system worked the following way: every potential customer provided numbers , and which the system temporarily accepted. are the time of arrival and departure. is the number of companions the customer comes with. Then at midnight the system has closed. Then it was supposed to execute the following algorithm: find the temporary reservation with earliest arrival time (in case of a tie, choose the one which was booked earlier). If there are enough fully empty tables to seat these guests, then confirm this reservation, else reject the reservation (sending an email to the customer). Note that the during the seating, minimal number of tables are assigned to the groups, that is if and , then tables should be reserved, even if there are more available. Another important condition is not to mix different groups, that is if and there are no empty tables but there are a partially filled table with free seats, then the reservation must be rejected. Example: let
The third reservation was rejected because of lack of tables. The first reservation is confirmed, the second one as well, since at the time of their arrival there are two empty tables. The fourth reservation is rejected. The fifth is confirmed. Overall there are rejected reservations. Please help Peter by writing a program which calculates the number of rejected reservations!Input specificationOn the first line of the input, there are numbers: , , . Each of the next lines contains integers: . The information (arrival, departure and number of guests (the group size)) about the th reservation. Output specificationOutput a single integer: the number of rejected reservations. Constraints
Sample input 1
Sample output 1
Sample input 2
Sample output 2
Sample input 3
Sample output 3
|
||||||||||||||||||||
University of Debrecen; Faculty of Informatics; v. 09/30/2024 |