Untitled
raw download clone
C
views 22
,
size 716 b
#include<stdio.h>
#define INF 1000000005
#define max(a, b) ((a>b) ? a : b)
#define min(a, b) ((a<b) ? a : b)

int main(void){
	int t, n, m, k;
	int temp, com; //暫存用
	int ans=0;
	int ai[5001];

	scanf("%d",&t);

	for(int i=0;i<t;i++){

		scanf("%d %d %d",&n,&m,&k);

		if(k>=m){
                k = m-1;
		}
		for(int i = 0; ai< n; i++){
			scanf("%d", &ai[i]);
		}
		ans=0;

		for(int j=0;j<=k;j++){
			temp=INF;
			for(int r=0;r<=m-1-k;r++){

				com = max(ai[j+r], ai[j+r+n-m]); //比較頭尾的大小,com存入較大數字

				if(com <= temp) temp = com; //取較小值
			}
			if(temp >= ans) ans = temp; //取較大值
		}
		printf("%d\n", ans);
	}
	return 0;
}
close fullscreen
Login or Register to edit or fork this paste. It's free.