#C597. Reservation Addition Without Overlap
Reservation Addition Without Overlap
Reservation Addition Without Overlap
You are given a schedule of reservations. Each reservation is represented by a start time and an end time, forming an interval. You are also given a new reservation. Your task is to determine whether the new reservation can be added to the schedule without overlapping any of the existing reservations.
Two reservations (intervals) are considered overlapping if they share any common time point. Mathematically, if the new reservation is \([a, b]\) and an existing reservation is \([c, d]\), they do not overlap if \(b d\). Otherwise, they overlap.
The input format is as follows: the first line contains an integer \(N\) representing the number of existing reservations. The next \(N\) lines each contain two space-separated integers representing the start and end times of a reservation. The last line contains two space-separated integers representing the start and end times of the new reservation. The output should be a single line with either True
(if the new reservation does not overlap with any existing reservation) or False
(otherwise).
inputFormat
The first line contains an integer N, the number of existing reservations. Each of the next N lines contains two space-separated integers indicating the start and end times of a reservation. The final line contains two space-separated integers representing the new reservation's start and end times.
outputFormat
Output a single line: 'True' if the new reservation can be added without overlapping any existing reservations, and 'False' otherwise.## sample
3
1 3
4 6
8 10
11 12
True