#P8856. Train Ticket Booking Problem
Train Ticket Booking Problem
Train Ticket Booking Problem
A train departs from city 1 and heads towards city \( C \). The train has \( S \) seats available, and there are \( R \) ticket booking requests. Each booking request is given by three integers \( O \), \( D \), and \( N \), representing that \( N \) seats are to be booked from city \( O \) to city \( D \) (i.e. for each segment from \( O \) to \( D-1 \)).
A booking can be satisfied if for every segment in the journey (from city \( O \) to \( D-1 \)) there are at least \( N \) seats still available. If so, the booking is accepted and the seats are deducted from the available seats on those segments; otherwise, the booking is rejected.
Process the bookings in the order given and, for each booking, determine whether it can be satisfied.
inputFormat
The first line contains three integers \( C \), \( S \), and \( R \) representing the destination city number, the number of seats in the train, and the number of booking requests, respectively.
Each of the next \( R \) lines contains three integers \( O \), \( D \), and \( N \) representing a booking request from city \( O \) to city \( D \) for \( N \) seats.
outputFormat
For each booking request, output a line containing Yes if the booking can be satisfied, or No otherwise.
sample
5 10 3
1 3 5
2 5 6
3 5 5Yes
No
Yes
</p>