Follows 10107.c (Total 77 lines):

/* @JUDGE_ID:4461XX 10107 C */
/* A */
#include<stdio.h>
#define MAX 10000

struct DataArray{
	int value ;
	int from ;
	int next ;
}arr[MAX] ;
int head , tail ;
void insert_head( int num )
{
	tail++ ;
	arr[tail].value = num ;
	arr[tail].from = -1 ;
	arr[tail].next = head ;
	arr[head].from = tail ;
	head = tail ;
}
void insert_tail( int num )
{
	int i ;
	
	for( i=head ; ; i=arr[i].next )
		if( arr[i].next==-1 ) break ;
	
	tail++ ;
	arr[tail].value = num ;
	arr[tail].from = i ;
	arr[tail].next = -1 ;
	arr[i].next = tail ;
}
void insert_middle( int num , int i )
{
	tail++ ;
	arr[tail].value = num ;
	arr[tail].from = arr[i].from ;
	arr[tail].next = i ;
	arr[ arr[i].from ].next = tail ;
	arr[i].from = tail ;
}
int search( int where )
{
	int i , j ;

	for( i=head,j=1 ; j<where ; j++ ) i = arr[i].next ;

	return arr[i].value ;
}
int main( void )
{
	int n , i ;

	scanf( "%d" , &n ) ;
	head = tail = 0 ;
	arr[0].value = n ;
	arr[0].from = arr[0].next = -1 ;
	printf( "%d\n" , arr[0].value ) ;

	while( scanf( "%d" , &n )==1 ){
		for( i=head ; i!=-1 ; i=arr[i].next ) /* liner-search */
			if( arr[i].value>n ) break ;

		if( i==head ) insert_head( n ) ;
		else if( i==-1 ) insert_tail( n ) ;
		else insert_middle( n , i ) ;

		if( (tail+1)%2 ) /* odd */
			printf( "%d\n" , search( (tail+2)/2 ) ) ;
		else /* even */
			printf( "%d\n" , ( search( (tail+1)/2 )+search( (tail+1)/2+1 ) )/2 ) ;
	}
	
	return 0 ;
}
/* @END_OF_SOURCE_CODE */

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