编程介的小学生 2019-01-22 12:25 采纳率: 20.5%
浏览 179

一个有关数据结构方面的广义表的算法的问题,如何采用的是C语言的实现编程

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

Hint: In the second case, you can make L1 = {(1,2), (3,4)} and L2 = {(2,1), (4,3)}, or L1 = {(1,2), (4,3)} and L2 = {(2,1), (3,4)}.

  • 写回答

1条回答 默认 最新

  • threenewbee 2020-02-03 22:16
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 一道python难题2
  • ¥15 一道python难题
  • ¥15 用matlab 设计一个不动点迭代法求解非线性方程组的代码
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试
  • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
  • ¥15 教务系统账号被盗号如何追溯设备