Follows 497.c (Total 38 lines):

/* @JUDGE_ID:4461XX 497 C */
/* A */
#include <stdio.h>
void main( void )
{
	int time=0 , times ;
	scanf( "%d\n" , × ) ;
	while( time<times ){
		int n=0 , i , j , ofbig=0 , max=1 ;
		int num[2000] , top[2000] , print[2000] ;
		char a[10] ;
		while( gets( a ) ){
			if( strlen( a )==0 ) break ;
			sscanf( a , "%d" , &num[n] ) ;
			n++ ;
		}
		for( i=0 ; i<n ; i++ ) top[i] = 1 ;
		for( i=1 ; i<n ; i++ ){
			for( j=i-1 ; j>=0 ; j-- )
				if( num[i]>num[j] && top[j]>ofbig ) ofbig = top[j] ;
			top[i] = ofbig + 1 ;
			ofbig = 0 ;
			if( top[i]>max ) max = top[i] ;
		}
		printf( "Max hits: %d\n" , max ) ;
		j = 0 ;
		for( i=n-1 ; i>=0 ; i-- )
			if( top[i]==max ){
				print[j] = num[i] ;
				max-- ;
				j++ ;
			}
		for( i=j-1 ; i>=0 ; i-- )
			printf( "%d\n" , print[i] ) ;
		putchar( '\n' ) ;
		time++ ;
	}
}

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