编程介的小学生 2019-05-14 20:37 采纳率: 20.5%
浏览 114

多次的计算的子序列算法问题,怎么采用的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

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 MATLAB动图的问题
    • ¥15 求差集那个函数有问题,有无佬可以解决
    • ¥15 【提问】基于Invest的水源涵养
    • ¥20 微信网友居然可以通过vx号找到我绑的手机号
    • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
    • ¥15 解riccati方程组
    • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
    • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
    • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
    • ¥50 树莓派安卓APK系统签名