最长公共上升子序列 LCIS 看这个博客 http://www.cnblogs.com/nuoyan2010/archive/2012/10/17/2728289.html
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std; int num1[],num2[],dp[][];
int main( )
{
int N,M,T; scanf("%d",&T);
while( T-- )
{
scanf("%d",&N);
for( int i = ; i <= N; i++ )scanf("%d",&num1[i]);
scanf("%d",&M);
for( int i = ; i <= M; i++ )scanf("%d",&num2[i]);
memset( dp,,sizeof(dp) );
for( int i = ; i <= N; i++ )
{
int Max = ;
for( int j = ; j <= M; j++ )
{
if( num1[i] > num2[j] && dp[i-][j] > Max )Max = dp[i-][j];
if( num1[i] == num2[j] )
dp[i][j] = Max + ;
else dp[i][j] = dp[i-][j];
}
}
int res = ;
for( int i = ; i <= M; i++ )res = max( res,dp[N][i] );
cout<<res<<endl;
if( T )puts("");
}
return ;
}