cswork / OAOpen practice workspace

Goldman SachsOA #17

Process Scheduler

Estimated MediumJudge-ready

Topics (AI-labelled)Prefix & RangesStacks & Heaps

Each process runs at every integer time from start to end, with both endpoints included. Find the maximum number of processes running at the same moment, which is the minimum number of cores required.

Input

The first line contains n (1..100000), followed by n lines, each with start[i] end[i], satisfying 1≤start≤end≤10^9.

Output

Output the minimum number of cores required.

Example 1

Input:

3
1 3
2 4
4 4

Output:

2

Example 2

Input:

1
1 1

Output:

1

Example 3

Input:

3
1 10
2 3
4 5

Output:

2

Editorial

Loading solution…