#C10131. Range Inclusion Query
Range Inclusion Query
Range Inclusion Query
You are given a list of integer ranges and a target integer. Your task is to determine whether the target integer lies within any of the given ranges. A range is defined by two integers 〈start, end〉 and it is inclusive, that is, the target is considered within the range if start ≤ target ≤ end.
Formally, for each range \( [a_i, b_i] \), check if the condition
\[
a_i \leq target \leq b_i
\]
holds. If it holds for at least one range, output True
; otherwise, output False
.
The input is provided via standard input (stdin) and the output should be written to standard output (stdout).
inputFormat
The input is read from standard input and has the following format:
r start1 end1 start2 end2 ... startr endr target
Here, r
is the number of ranges. Each of the next r
lines contains two space-separated integers representing the start and end of a range (inclusive). The last line contains an integer target
which is the number you need to check against the ranges.
outputFormat
Output a single line to standard output. The line should contain either True
if the target lies within at least one of the provided ranges, or False
otherwise.
3
1 5
10 15
20 25
3
True