#K88807. Calendar Event Manager
Calendar Event Manager
Calendar Event Manager
You are given a calendar that supports three types of operations:
- Add Event: Add an event with a start time s and an end time e.
- Remove Event: Remove an event with a given start time s and end time e. It is guaranteed that a removal request applies only to an event that was previously added and not yet removed.
- Query Maximum Overlap: Compute the maximum number of events overlapping at any time point so far.
The maximum overlap is calculated using the sweep line algorithm. Mathematically, if you denote the changes at time t by \( \Delta(t) \), the overlapping events at a time are given by:
\[ \text{overlap}(t) = \sum_{u \le t} \Delta(u) \]Your task is to process a series of queries and, for each query of type 3, output the current maximum overlap.
inputFormat
The first line contains an integer \(Q\) which denotes the number of queries. Each of the following \(Q\) lines describes a query in one of the following formats:
1 s e
: Add an event with start time \(s\) and end time \(e\).2 s e
: Remove an event with start time \(s\) and end time \(e\).3
: Output the maximum number of overlapping events at the current moment.
All values are separated by spaces, and each query appears on a new line.
outputFormat
For each query of type 3, output a single integer on a new line representing the maximum number of overlapping events at that moment.
## sample4
1 1 5
1 2 6
1 4 8
3
3
</p>