#C8877. Restaurant Reservation Capacity Check
Restaurant Reservation Capacity Check
Restaurant Reservation Capacity Check
You are given a restaurant with a seating capacity of \( m \) and \( n \) reservations. Each reservation is described by three integers \( s_i \), \( e_i \), and \( g_i \), representing the start time, end time (in minutes past midnight), and the number of guests for that reservation respectively. The restaurant operates with a discrete minute granularity from 0 to 1440. Your task is to determine whether the restaurant can accommodate all the reservations without ever exceeding its seating capacity.
Formally, for each minute \( t \) in the interval \([0, 1440]\), compute the total number of guests present by summing \( g_i \) for all reservations where \( s_i \leq t < e_i \). The condition to check is: \[ \text{current guests}(t) \leq m \quad \text{for all } t \in [0,1440] \]
If the condition holds, print Yes
; otherwise, print No
.
inputFormat
The input is given via standard input in the following format:
n m s1 e1 g1 s2 e2 g2 ... sn en gn
Where:
n
is the number of reservations,m
is the seating capacity,- Each of the next
n
lines contains three integers: \( s_i \) (start time), \( e_i \) (end time) and \( g_i \) (number of guests).
outputFormat
Output a single line to standard output containing Yes
if the restaurant can accommodate all reservations without exceeding the capacity at any moment, or No
otherwise.
3 10
0 60 4
30 90 5
70 120 3
Yes