#C7006. Check Appointment Overlap
Check Appointment Overlap
Check Appointment Overlap
You are given a list of existing appointments and a new appointment. Each appointment is represented by a pair of integers start_time and end_time, which indicate the starting and ending times respectively.
An appointment is considered valid if it does not overlap with any of the existing appointments. Two appointments are considered to overlap if they share any time in common. Note that if one appointment ends exactly when another begins, they do not overlap.
Your task is to determine whether the new appointment can be scheduled without conflicting with any of the existing appointments.
The condition for no overlap between the new appointment [a, b] and an existing appointment [c, d] is given by:
\( b \leq c \quad \text{or} \quad a \geq d \)
If this condition holds for all existing appointments, the new appointment is valid.
inputFormat
The input is read from standard input (stdin) and it is structured as follows:
- The first line contains an integer n representing the number of existing appointments.
- The next n lines each contain two integers separated by a space: the start time and end time of an appointment.
- The last line contains two integers separated by a space representing the start time and end time of the new appointment.
outputFormat
Output to standard output (stdout) a single line containing either True
if the new appointment does not overlap with any existing appointments, or False
if it does overlap.
3
9 11
13 15
16 18
11 13
True