#include #include #include using namespace std; int shortest_fall_time(const int length, vector ant_pos) { sort(ant_pos.begin(), ant_pos.end(), [length](const int pos1, const int pos2) { return abs(pos1 - length / 2) < abs(pos2 - length / 2); // 到中点距离最短者 }); return min(ant_pos[0], length - ant_pos[0]); } int longest_fall_time(const int length, vector ant_pos) { sort(ant_pos.begin(), ant_pos.end(), [length](const int pos1, const int pos2) { return abs(pos1 - length / 2) > abs(pos2 - length / 2); // 到中点距离最长者 }); return max(ant_pos[0], length - ant_pos[0]); } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int group_count; cin >> group_count; for (int _ = 0; _ < group_count; _++) { int length, ant_count; cin >> length >> ant_count; vector ant_pos(ant_count); for (int i = 0; i < ant_count; i++) { cin >> ant_pos[i]; } cout << shortest_fall_time(length, ant_pos) << " " << longest_fall_time(length, ant_pos) << endl; } return 0; }