#K66827. Maximum Interval Overlap

    ID: 32507 Type: Default 1000ms 256MiB

Maximum Interval Overlap

Maximum Interval Overlap

Given a collection of intervals on the number line, where each interval is represented by two integers \(l\) and \(r\) (both inclusive), determine the maximum number of intervals that overlap at any point. In other words, find the maximum value of

\[ \max_{x}\; \sum_{(l, r)} \mathbf{1}(l \le x \le r), \]

where \(\mathbf{1}(condition)\) is the indicator function which is 1 if the condition holds and 0 otherwise.

The problem requires you to take the input from stdin and output the result to stdout.

inputFormat

The first line contains an integer \(N\), the number of intervals.

Each of the following \(N\) lines contains two integers \(l\) and \(r\) (\(l \le r\)), representing an interval [l, r].

outputFormat

Output a single integer representing the maximum number of intervals that overlap at any point.

## sample
5
1 4
2 5
9 12
5 9
5 12
3

</p>