#K12196. Log System Query
Log System Query
Log System Query
You are given a log system that supports two types of operations:
Add Operation: add timestamp severity
adds a log with a given timestamp and severity.
Query Operation: query start_time end_time
queries the highest severity among all logs whose timestamp lies in the inclusive interval \( [start\_time,\ end\_time] \). If there is no log in the range, output -1.
Input Format: The first line contains a single integer \( n \) representing the number of operations. Each of the following \( n \) lines is either an add operation or a query operation as described.
Output Format: For each query operation, output the result on its own line.
inputFormat
The first line contains an integer \( n \) (1 \( \leq n \leq 10^5 \)) — the number of operations. Each of the next \( n \) lines contains an operation in one of the following formats:
add timestamp severity
— add a log with a given timestamp (an integer) and severity (an integer).query start_time end_time
— query and output the highest severity among all logs with timestamp in the inclusive interval \( [start\_time,\ end\_time] \).
If there are no logs in the queried range, output -1.
outputFormat
For each query operation, print a single line containing the highest severity in the specified time range, or -1 if no such log exists.
## sample6
add 1 5
add 10 3
add 15 7
query 1 10
query 1 15
query 2 2
5
7
-1
</p>