QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 256 MB Total points: 100

#22681. Rain Cover

Statistics

The farm has suffered an extraordinary amount of rain lately. Now wanting to eat free from rain, the ingenious cows have set up $N$ ($1 \le N \le 25{,}000$) rectangular umbrellas to shield them from the rain while they are grazing.

The cows' field is a single strip of grass, and each umbrella completely covers some interval of grass. However, they have set up the umbrellas in a most haphazard way, and some of the umbrellas cover all or part of an area covered by one or more other umbrellas. Your task is to find the greatest number of umbrellas whose areas are completely covered by a single umbrella.

Input

  • Line 1: The single integer $N$
  • Lines $2..N+1$: Two space-separated integers, $A$ and $B$ ($1 \le A < B \le 2{,}000{,}000{,}000$) that are the endpoints of the interval of grass covered by an umbrella. No endpoint is shared by any two umbrellas.

Output

  • Line 1: A single integer that is the maximum number of umbrellas whose coverage is entirely within the area covered by another single umbrella.

Examples

Input 1

4
1 7
2 3
5 6
4 10

Output 1

2

Output Details

The first umbrella covers the second and third umbrellas, as seen below:

      *-----------*
      |           |
*-----------*
|           |
| *-*   *-* |
| | |   | | |
1 2 3 4 5 6 7 8 9 10

Problem credits: Alex Schwendner, 2003

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.