#C401. Temperature Package Compliance Check
Temperature Package Compliance Check
Temperature Package Compliance Check
During the transportation of temperature-sensitive drug packages, it is crucial that each package is kept within its designated acceptable temperature range throughout the journey. Each package has an acceptable temperature range represented by an interval \([l_i, u_i]\). Additionally, a series of temperature readings are recorded during the transport. For every recorded temperature reading, the temperature must lie within every package's acceptable range to ensure that all packages are properly maintained.
You are given:
- An integer
n
which represents the number of packages. n
pairs of integers \(l_i\) and \(u_i\), each representing the lower and upper bound of the acceptable temperature range for the packages.- An integer
m
which represents the number of temperature readings recorded during the transportation. m
pairs of integers, where each pair consists of a time stamp and a temperature reading.
The task is to check whether all temperature readings satisfy the acceptable range \([l_i, u_i]\) for every package. If any reading falls outside any one package's temperature range, the result should be NO
; otherwise, output YES
.
Note: All formulas are in \(\LaTeX\) format. The condition can be summarized as: For every temperature reading \(x\) and every package range \([l_i, u_i]\), it must hold that \(l_i \le x \le u_i\).
inputFormat
The input is read from stdin and has the following format:
n l1 u1 l2 u2 ... ln un m t1 x1 t2 x2 ... tm xm
Where:
n
is an integer representing the number of packages.- Each of the next
n
lines contains two integersl_i
andu_i
representing the acceptable temperature range for a package. m
is an integer representing the number of temperature readings.- Each of the next
m
lines contains two integers: the first is a time stamp (which can be ignored for the checking) and the second is the temperature reading.
outputFormat
Output a single line to stdout containing either YES
if all temperature readings fall within every package's acceptable range, or NO
otherwise.
3
2 8
0 5
-1 3
4
1 4
2 6
3 1
4 -2
NO