#C9150. Festivities Overlap
Festivities Overlap
Festivities Overlap
You are given a list of time intervals representing festivities. Each festivity is represented by a pair of integers a and b indicating its start day and end day, respectively. Your task is to determine whether any two festivities overlap.
Formally, let the intervals be \( (a_1,b_1), (a_2,b_2), \dots, (a_n,b_n) \). First, sort the intervals in non-decreasing order based on their start time \(a_i\). Two consecutive intervals \( (a_i,b_i) \) and \( (a_{i+1},b_{i+1}) \) are said to overlap if and only if \( b_i \geq a_{i+1} \). If any such overlap exists, print "Yes"; otherwise, print "No".
Note: If the list is empty, output "No".
inputFormat
The input is given via standard input (stdin) and has the following format:
n A1 B1 A2 B2 ... An Bn
Here, the first line contains an integer n indicating the number of festivities. Each of the next n lines contains two space-separated integers Ai and Bi representing the start and end of the festivity, respectively.
outputFormat
Print a single line to standard output (stdout) containing "Yes" if any two festivities overlap, and "No" otherwise.
## sample3
12 19
20 25
26 30
No