编程介的小学生
2017-09-24 09:42This time, two, not one
Problem Description
I konw you guys have solve so many problems about increasing sequence, this time, a little change has been made.
Assume that there is a sequence S = {s1, s2, s3, ..., sn}, si = (xi, yi).You should find two increasing subsequence L1 and L2, and they have no common elements, means L1∩L2 = φ, and the sum of their lenth is as max as possible.
Here we assume si > sj is that (xi > xj && yi > yj) or (xi >= xj && yi > yj) or (xi > xj && yi >= yj). I will ensure that all elements' coordinates are distinct, i.e., si != sj (i!=j).
Input
The input consists of multiple test cases. Each case begins with a line containing a positive integer n that is the length of the sequence S, the next n lines each contains a pair integers (xi, yi), i = 1,...n.1 <= n <= 5000,1<=xi,yi<=2^31.
Output
For each test case, output one line containing the the maximum sum of the two increasing subsequence L1 and L2 you can find.
Sample Input
3
1 3
3 1
2 2
4
1 2
2 1
4 3
3 4
Sample Output
2
4
- 点赞
- 回答
- 收藏
- 复制链接分享
1条回答
为你推荐
- This time, two, not one
- lines
- as
- each
- 1个回答
- What Is the Time Now
- lines
- it
- mm
- 1个回答
- Maximize Game Time
- play
- numbers
- Golang
- 2个回答
- Average is not Fast Enough!
- mm
- numbers
- 1个回答
- This time, two, not one
- lines
- 1个回答