相比 HDOJ 的 fatmouse‘s speed 这道题只需要输出 最长子序列的长度
#include<iostream>
using namespace std;
#define Size 1000
int main()
{
int N1;
int table[Size+1];
int a[Size+1];
cin>>N1;
for( int i=0; i<N1; i++ )
{
int N2;
int ans=0;
cin>>N2;
for( int j=0; j<N2; j++ )
{
cin>>a[j];
table[j]=1;
for( int k=0; k<j; k++ )
if( a[j]>a[k] && table[j]<table[k]+1 )
table[j]=table[k]+1;
if( table[j]>ans )
ans = table[j];
}
if( i )
cout<<endl;
cout<<ans<<endl;
}
return 0;
}
ZOJ- 2136 Longest Ordered Subsequence
原文:http://www.cnblogs.com/FightForCMU/p/4631270.html