Follows 111.c (Total 30 lines):

/* @JUDGE_ID:4461XX 111 C */
/* A */
#include<stdio.h>
void main( void )
{
	int n , arr[3][20] , k , i , j , big ;
/*	freopen( "c:\\windows\\desktop\\111.in" , "r" , stdin ) ;
	freopen( "c:\\windows\\desktop\\111.out" , "w" , stdout ) ;*/
	scanf( "%d" , &n ) ;
	for( i=0 ; i<n ; i++ ) scanf( "%d" , &arr[0][i] ) ;
	while( 1 ){
		if( scanf( "%d" , &k ) != 1 ) break ;
		arr[1][k-1] = 1 ;
		for( i=2 ; i<=n ; i++ ){
			scanf( "%d" , &k ) ;
			arr[1][k-1] = i ;
		}
		arr[2][0] = 1 ;
		for( i=1 ; i<n ; i++ ){
			big = 0 ;
			for( j=i-1 ; j>=0 ; j-- )
				if( arr[0][arr[1][j]-1] < arr[0][arr[1][i]-1] && arr[2][j] > big ) big = arr[2][j] ;
			arr[2][i] = big + 1 ;
		}
		big = 0 ;
		for( i=0 ; i<n ; i++ )
			if( arr[2][i] > big ) big = arr[2][i] ;
		printf( "%d\n" , big ) ;
	}
}

Back to statistics
Ya-Lin Huang (C)
huangyl@gmail.com