#C9404. Maximum Overlapping Events

    ID: 53494 Type: Default 1000ms 256MiB

Maximum Overlapping Events

Maximum Overlapping Events

You are given n events. Each event is described by two integers: the start day and the end day (inclusive). Your task is to determine the maximum number of events that are occurring simultaneously on any given day.

More formally, let an event be represented as a tuple \((s,e)\), where \(s\) and \(e\) are integers denoting the start and end days respectively. You are required to compute the maximum value of overlapping events, i.e. find the maximum count at any day \(d\) that satisfies:

[ \text{overlap}(d) = \sum_{(s,e)} I(s \le d \le e)\quad \text{and} \quad \max_d \text{overlap}(d). ]

Note: \(I(condition)\) is the indicator function which is 1 if the condition is true and 0 otherwise.

inputFormat

The input is given via standard input (stdin) in the following format:

n
s1 e1
s2 e2
... 
sn en

Here, n is the number of events, and each of the next n lines contains two integers separated by a space representing the start day (si) and end day (ei) of the i-th event.

outputFormat

Output a single integer to standard output (stdout) representing the maximum number of events that overlap on any given day.

## sample
1
1 1
1

</p>