cho.sh
Notes
Loading...

Overlapping Segments

Time limit

2s

Memory limit

256 MB

Problem

There are N line segments on a one-dimensional coordinate line. Find the maximum number of segments that overlap at the same point.

If two segments meet only at an endpoint, that contact is not counted as an overlap.

Input

The first line contains the number of segments N. (1 ≤ N ≤ 1,000,000)

Each of the next N lines contains two integers s and e, the start and end coordinates of a segment. It is always true that s < e. Every coordinate is an integer whose absolute value is at most 1,000,000,000.

Output

Print the maximum number of segments that overlap.