您的位置:首页 > 产品设计 > UI/UE

Pku1887----Testing the CATCHER (经典动态规划题:最长下降子序列),,,,,捎带pku2533---Longest Ordered Subsequence

2009-01-10 23:15 645 查看
280K63MSGCC600B2009-01-10 23:08:06
Code

#include<stdio.h>

int a[1005],best[1005];

int n;

void input()

{

int i;

scanf("%d",&n);n++;

for(i=1;i<n;i++)

scanf("%d",&a[i]);

}

void process()

{

int i,j,max;

best[1] = 1;max=1;

for(i=2;i<n;i++){

best[i] = 1;

for(j=1;j<i;j++){

if(a[j]<a[i]&&best[j]+1>best[i])

best[i]=best[j]+1;

}

if(best[i]>max)

max=best[i];

}

printf("%d\n",max);

}

int main()

{

input();

process();

return 0;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: