1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
#include <iostream> #include <algorithm> using namespace std;
const int MAXN = 1E6; int arr[MAXN];
int main() { ios::sync_with_stdio(false); int test; cin >> test; while(test--) { int l, n; cin >> l >> n; for(int i = 0; i < n; i++) cin >> arr[i]; int minT = 0; for(int i = 0; i < n; i++) { minT = max(minT, min(arr[i], l - arr[i])); }
int maxT = 0; for(int i = 0; i < n; i++) { maxT = max(maxT, max(arr[i], l - arr[i])); } cout << minT << " " << maxT << endl; } return 0; }
|