博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
poj 2533 Longest Ordered Subsequence
阅读量:2148 次
发布时间:2019-04-30

本文共 1367 字,大约阅读时间需要 4 分钟。

Longest Ordered Subsequence
Time Limit: 2000MS   Memory Limit: 65536K
Total Submissions: 46180   Accepted: 20509

Description

A numeric sequence of 
ai is ordered if 
a1 < 
a2 < ... < 
aN. Let the subsequence of the given numeric sequence (
a1
a2, ..., 
aN) be any sequence (
ai1
ai2, ..., 
aiK), where 1 <= 
i1 < 
i2 < ... < 
iK <= 
N. For example, sequence (1, 7, 3, 5, 9, 4, 8) has ordered subsequences, e. g., (1, 7), (3, 4, 8) and many others. All longest ordered subsequences are of length 4, e. g., (1, 3, 5, 8).
Your program, when given the numeric sequence, must find the length of its longest ordered subsequence.

Input

The first line of input file contains the length of sequence N. The second line contains the elements of sequence - N integers in the range from 0 to 10000 each, separated by spaces. 1 <= N <= 1000

Output

Output file must contain a single integer - the length of the longest ordered subsequence of the given sequence.

Sample Input

71 7 3 5 9 4 8

Sample Output

4

 
 
最大公共子串原题
#include 
#include
#include
using namespace std;int main(){ int n; int a[1005], dp[1005]; scanf("%d",&n); int i; for(i=0; i
=0; j--) { if(a[j]
ma)ma=dp[j]; } dp[i]=ma+1;// printf("%d ", dp[i]); if(dp[i]>y)y=dp[i]; } printf("%d\n", y); return 0;}

转载地址:http://kiywb.baihongyu.com/

你可能感兴趣的文章
Loadrunner之https协议录制回放报错如何解决?(九)
查看>>
python中xrange和range的异同
查看>>
列表、元组、集合、字典
查看>>
【Python】easygui小甲鱼
查看>>
【Python】关于Python多线程的一篇文章转载
查看>>
【Pyton】【小甲鱼】文件
查看>>
【Pyton】【小甲鱼】永久存储:腌制一缸美味的泡菜
查看>>
【Pyton】【小甲鱼】异常处理:你不可能总是对的
查看>>
APP性能测试工具
查看>>
【Pyton】【小甲鱼】类和对象
查看>>
压力测试工具JMeter入门教程
查看>>
作为一名软件测试工程师,需要具备哪些能力
查看>>
【Pyton】【小甲鱼】类和对象:一些相关的BIF(内置函数)
查看>>
【Pyton】【小甲鱼】魔法方法
查看>>
单元测试需要具备的技能和4大阶段的学习
查看>>
【Loadrunner】【浙江移动项目手写代码】代码备份
查看>>
Python几种并发实现方案的性能比较
查看>>
[Jmeter]jmeter之脚本录制与回放,优化(windows下的jmeter)
查看>>
Jmeter之正则
查看>>
【JMeter】1.9上考试jmeter测试调试
查看>>