Type: Default 1000ms 256MiB

最长上升子序列

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

题目描述

设有由image 个整数组成的数列,记为: image , 若存在 image 则称为长度为 e 的上升子序列。 程序要求,当原数列出之后,求出最长的上升子序列。

例如 13,7,9,16,38,24,37,18,44,19,21,22,63,15。 例中 13,16,18,19,21,22,63 就是一个长度为 7 的上升子序列, 同时也有 7 ,9,16,18,19,21,22,63 组成的长度为 8 的上升子序列。

输入格式

第一行为空格隔开的序列,即待求解最长上升子序列的母序列,0 < 序列长度 <=200。 你可以采用形如下面代码的形式输入这个数列。

int a[1005];
int n=0;
//本地调试时,输入0作为结束,提交前删除&&a[n]!=0
while(cin>>a[n]&&a[n]!=0){
    n++;
}

输出格式

第一行输出 max = 最长上升子序列的长度

样例

输入 #1复制

1 7 3 5 9 4 8

输出 #1复制

max=4

动态规划

Not Claimed
Status
Done
Problem
18
Open Since
2024-12-19 0:00
Deadline
2025-3-22 23:59
Extension
24 hour(s)