#K95427. Prime Scheduler
Prime Scheduler
Prime Scheduler
You are given a meeting scheduler that supports three operations:
- ADD s e: Add a meeting that starts at time s and ends at time e.
- CANCEL s e: Cancel the meeting that exactly matches the start time s and end time e.
- QUERY t: For a given time t, count the number of meetings ongoing at that moment. A meeting is ongoing if \(s \le t < e\).
The operations will be provided in sequence. Your task is to process all the operations and for every QUERY
command, output the corresponding number of ongoing meetings.
Note: The inequality for determining if a meeting is ongoing is given by:
$$s \le t < e$$
inputFormat
The first line of input contains an integer n, representing the number of operations.
The next n lines contain one operation per line in one of the following formats:
ADD s e
CANCEL s e
QUERY t
Here, s, e, and t are integers representing times.
outputFormat
For each QUERY
operation, output a single line with the number of meetings that are ongoing at time t.
10
ADD 900 1030
ADD 1100 1200
ADD 1500 1600
QUERY 930
ADD 1400 1500
QUERY 1430
CANCEL 1100 1200
QUERY 930
QUERY 1500
QUERY 1100
1
1
1
1
0
</p>