来源:POJ1852
代码:
#include <iostream>
#include <cstdio>
#include <cstdio>
#include <algorithm>
using namespace std;
const int MAXN =1e6+10;
int a[MAXN];
int minx,maxn;
const int INF = 0x3f3f3f3f;
int n,L;
int main()
{
int T;
scanf("%d",&T);
while(T--){
scanf("%d%d",&L,&n);
int tmp;
minx = 0;
maxn = 0;
for(int i=1;i<=n;i++){
scanf("%d",&tmp);
maxn = max(maxn,max(L-tmp,tmp));
minx = max(minx,min(L-tmp,tmp));
}
printf("%d %d\n",minx,maxn);
}
return 0;
}