找其中位數即可,由於輸入的資料皆已排序過,找其一半的地方即是答案。
C++(0.008)
/*******************************************************/
/* UVa 11875 Brick Game */
/* Author: LanyiKnight [at] knightzone.studio */
/* Version: 2012/10/17 */
/*******************************************************/
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
int T;
int N;
int teammate[15];
while( scanf( "%d", &T ) != EOF ){
for( int i = 1 ; i <= T ; i++ ){
scanf( "%d", &N );
for( int j = 0 ; j < N ; j++ )
scanf( "%d", &teammate[j] );
printf( "Case %d: %d\n", i, teammate[N/2] );
}
}
return 0;
}