思考:很有意思的一道题目。
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
int Max(const int x, const int y) {
return x > y ? x : y;
}
int Min(const int x,const int y) {
return x > y ? y : x;
}
int main()
{
int T;
scanf("%d", &T);
while(T--)
{
int length, number;
int loc;
int early = -1, late = -1;
scanf("%d%d", &length, &number);
for(int i = 1; i <= number; i++) {
scanf("%d", &loc);
early = Max(early, Min(loc, length-loc));
late = Max(late, Max(loc, length-loc));
}
printf("%d %d\n", early, late);
}
return 0;
}