10714
最小的显而易见,最大的类似求即可
//============================================================================
// Name : 10714.cpp
// Author :
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <iostream>
#include <cstdio>
using namespace std;
int t, Min, Max, N, l, n;
int main() {
scanf("%d", &N);
while(N--){
scanf("%d%d", &l, &n);
Min = 0;
Max = 0;
for(int i = 0;i < n;i++){
scanf("%d", &t);
if(Min < (t < l-t?t:l-t)){
Min = t < l-t?t:l-t;
}
if(Max < (t > l-t?t:l-t)){
Max = t > l-t?t:l-t;
}
}
printf("%d %d\n", Min, Max);
}
return 0;
}

浙公网安备 33010602011771号