AmazonOA #302
Minimum Retailers
估计中等可在线判题
Each merchant corresponds to a closed interval. Delete the fewest merchants so that the remaining merchants include a center merchant whose interval intersects the interval of every other remaining merchant. Sharing an endpoint counts as intersecting. All intervals do not need a common point, and it is not enough for them to be connected as a whole.
输入格式
The first line contains n, followed by n lines of start end. The original bounds are 1≤n≤100000, 1≤start≤end≤10^9, and duplicate intervals are allowed.
输出格式
Output a single integer, the answer.
样例 1
输入:
5
3 8
4 5
6 7
10 11
12 13
输出:
2
样例 2
输入:
2
1 2
2 3
输出:
0
样例 3
输入:
3
1 1
3 3
5 5
输出:
2
样例说明
The answers are 2, 0 and 2. In the first example the center [3,8] touches two disjoint small intervals at once, so the maximum simultaneous coverage cannot be used instead.