#K60277. Temperature Range Query
Temperature Range Query
Temperature Range Query
You are given n temperature records. Each record contains a time and a temperature value. After that, you are given q queries. Each query specifies an interval [start, end]. For each query, if there is at least one record whose time lies within the inclusive range \( [start, end] \), output the minimum and maximum temperature observed in that interval. If no record exists within the interval, do not output anything for that query.
Note: Time values can be non-sequential and records may appear in any order.
inputFormat
The input is read from standard input and has the following format:
- An integer
n
representing the number of temperature records. n
lines follow, each line contains two integers:time
andtemperature
.- An integer
q
representing the number of queries. q
lines follow, each line contains two integers:start
andend
representing the inclusive time interval of the query.
outputFormat
For each query that has at least one record in the specified interval, output a line with two integers separated by a space: the minimum and maximum temperatures for that query. If a query does not include any record, output nothing for that query.
## sample1
1 30
1
1 1
30 30
</p>