#K3146. Schedule Validity Checker
Schedule Validity Checker
Schedule Validity Checker
In this problem, you are given a list of events where each event is associated with a room, a start time, and an end time. Your task is to determine if the schedule is valid. An event in a room is considered non-overlapping if it starts when the previous event in that room has ended. However, if an event starts before the previous event in the same room finishes, the schedule is invalid.
Mathematically, for events in the same room sorted by their start times, if \( s_i \) and \( e_i \) denote the start and end times respectively for the \( i^{th} \) event, the schedule is valid if for every \( i \geq 2 \), \( s_i \geq e_{i-1} \). Otherwise, the schedule is invalid.
Output "YES" if the schedule does not have any overlapping events in the same room, otherwise output "NO".
inputFormat
The input is given via standard input (stdin). The first line contains an integer \( N \) denoting the number of events. The next \( N \) lines each contain an event description consisting of a room name (a string) and two integers representing the start and end times of the event, respectively, separated by spaces.
outputFormat
Print a single line to standard output (stdout): "YES" if the schedule is valid, or "NO" if there is an overlap of events within the same room.
## sample3
RoomA 1 5
RoomB 2 6
RoomA 5 10
YES
</p>