#K94487. Flower Bed Overlap
Flower Bed Overlap
Flower Bed Overlap
You are given a list of existing flower beds, each represented as an interval [a, b)
with a < b
. A new flower bed is also given as an interval [a_{new}, b_{new})
. Your task is to determine whether the new flower bed overlaps with any of the existing ones.
Two intervals [a, b)
and [c, d)
are said to overlap if and only if
If there is an overlap with any existing flower bed, output Yes
; otherwise, output No
.
inputFormat
The input is given through standard input (stdin) and has the following format:
- The first line contains an integer
n
, the number of existing flower beds. - The next
n
lines each contain two integersa
andb
(witha < b
), representing an existing flower bed. - The last line contains two integers representing the new flower bed:
anew
andbnew
.
outputFormat
Output a single line to standard output (stdout): Yes
if the new flower bed overlaps with any existing flower bed, otherwise No
.
2
2 4
10 14
5 9
No
</p>