题目描述
题目思路
纯板子题,与如出一辙。
我的代码
注意士兵数可能为0。
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
int l;
int n;
cin >> l >> n;
int near = -1;
int far = -1;
if (n != 0) {
while (n--) {
int t;
cin >> t;
int t2 = l - t + 1;
near = max(min(t, t2), near);
far = max(max(t, t2), far);
}
cout << near << " " << far << endl;
}
else {
cout << 0 << " " << 0;
}
return 0;
}