#t360. 零件分组
零件分组
Parts Grouping
Problem Background
Special for beginners, ^_^
Problem Description
A factory produces a batch of rod-shaped parts, each with a certain length () and weight (). For processing purposes, they must be divided into several groups so that within each group the parts can be arranged into a sequence whose lengths and weights are both non-decreasing (if , then ). What is the minimum number of groups?
Input Format
The first line is an integer , the number of parts. The second line contains pairs of positive integers, each pair being the length and weight of a part; both length and weight do not exceed .
Output Format
Exactly one line: the minimum number of groups.
Sample Input
5
8 4 3 8 2 3 9 7 3 5
Sample Output
2
Constraints
1s, 1024KiB for each test case.