很久没写了,第一个程序。 注意每个case前都要初始化 //#define LOCAL#include cstdio#include cstring#include algorithmusing namespace std;int main(){#ifdef LOCAL freopen("data.in", "r", stdin); //freopen("datd.out", "w", s
很久没写了,第一个程序。
注意每个case前都要初始化
//#define LOCAL
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int main(){
#ifdef LOCAL
freopen("data.in", "r", stdin);
//freopen("datd.out", "w", stdout);
#endif
int cases;
int n;
int length;
int num;
int maxx;
int minn;
scanf("%d", &cases);
for(int s = 0; s < cases; s++){
maxx = 0;
minn = 0;
scanf("%d%d", &length, &n);
for(int i = 0; i < n; i++){
scanf("%d", &num);
if(num > length)
continue;
maxx = max(maxx, max(num, length - num));
minn = max(minn, min(num, length - num));
//printf("MIN:%d MAX:%d\n", minn, maxx);
}
printf("%d %d\n", minn, maxx);
}
return 0;
}