Lake
Time limit1sMemory limit1024 MB
Given chords between distinct points on a circle, find the maximum number of chords that can be chosen so that no two chosen chords cross.
- Level
Medium7 of 10
- Topics
- Dynamic programming, Intervals, Sorting, Geometry
- Solved
- No attempts yet
Problem
In southeastern Canada, on the border with the United States, lie the five well-known lakes called the Great Lakes. Now that the IOI is being held in Canada, several proposals have come up to run sightseeing boats on Lake Ontario, the lake closest to the venue.
Each sightseeing boat proposal connects two points on the shore of the lake, and there are N proposals in total. The i-th proposal is to run a sightseeing boat connecting point and point . Here point means the point reached by traveling a distance of meters counterclockwise along the shore from the eastern end of the lake. The circumference of the lake is 500,000 meters.
We want to carry out as many of these proposals as possible, but to avoid collisions between boats, two routes must not cross.
Given N boat proposals, write a program to find the maximum number of proposals that can be carried out.
Input
Read the following input from standard input.
- The first line of the input contains the integer N. It represents the number of sightseeing boat proposals.
- The i+1-th line of the input () contains two integers separated by a space. They represent the two points to be connected by the i-th proposal. The values are all distinct.
Output
Print to standard output a single integer representing the maximum number of proposals that can be carried out among the given boat proposals.
Constraints
- (number of proposals)
- , (coordinates of points)
Hint

A figure showing the five proposals in the input example above (the spacing between points is not exact). If you choose the three proposals drawn with thick lines, the boats can be run without their routes crossing.