Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

哪位帮看看这个题怎么做,最好给出源码,谢谢

Posted by kisonlee at 2008-06-12 20:23:01
Description

There is a long long corridor. Only one side of the long corridor have many rooms and there are many boxes in some rooms. Porters will carry the boxes from a room to another room. The corridor can only allow one porter to get across with a box. Any two porters cannot be at the same position of the corridor and they also cannot enter or leave the room at the same time.
However, porters are very strange. They always use the same time to carry a box from a room to another room. No matter how long the route is. Well, your boss ask you to compute at least how many times the porters can finish all the tasks.





Input

This problem have several test cases. For each test case:
The first line contains one number n ( 1 ≤ n ≤ 30000 ), the total number of the tasks.
Following n lines, each line contains two numbers, a and b ( 0 ≤ a < b ≤ 1000000000 ), indicate the porters must carry a box from room a to room b.


Output

For each test case, output only contains one line, show the minimum times they need to finish the tasks.


Sample Input

3
2 4
3 5
2 5


Sample Output

2


Source

Louty


Hint

Task 1 and Task 2 can finish at one time.
And Task 3 finish in the second time alone.
Note:
Task 1 and Task 3 cannot finish at one time because two porters will leave the room 2 at the same time.
Task 2 and Task 3 cannot finish at one time because two porters will enter the room 5 at the same time.

Room 0 may appear in test cases. And Room 0 is in front of Room 1.


Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator