#K44947. Maximum Overlapping Events

    ID: 27644 Type: Default 1000ms 256MiB

Maximum Overlapping Events

Maximum Overlapping Events

You are given a list of events. Each event is represented by a pair of integers, indicating its start time and end time. Your task is to compute the maximum number of events that are overlapping at any point in time.

Formally, if the events are given as \((s_i, e_i)\) for \(i=1,2,\dots,N\), you need to find the maximum number \(k\) such that there exists a time \(t\) where at least \(k\) events satisfy \(s_i \le t < e_i\). Note that an event ending at time \(t\) does not count as overlapping an event starting at time \(t\).

Input: The first line contains an integer \(N\), representing the number of events. Each of the following \(N\) lines contains two integers, representing the start time and the end time of an event.

Output: Output a single integer which is the maximum count of overlapping events at any point in time.

inputFormat

The input is read from standard input (stdin) and has the following format:

N
s1 e1
s2 e2
... 
sN eN

where \(N\) is the number of events, and each subsequent line contains two space-separated integers representing the start and end times of an event.

outputFormat

The output is a single integer printed to standard output (stdout) which represents the maximum number of overlapping events.

## sample
3
1 4
2 5
3 6
3