洛谷P1007 独木桥——思维题
作者:互联网
遭受了普及-的智商碾压orz
其实就是说
两个人相遇后调头,
和互相穿过
完 全 等 价 啊
!!!
想到这一点就是入门-了吧
#include <iostream>
#include <algorithm>
using namespace std;
const int maxn = 5e3 + 10;
int n, l, a[maxn], ans1, ans2;
int main() {
cin >> l >> n;
for (int i = 1; i <= n; i++) cin >> a[i];
sort(a + 1, a + 1 + n);
for (int i = 1; i <= n; i++) {
ans1 = max(ans1, min(a[i], l - a[i] + 1));
ans2 = max(ans2, max(a[i], l - a[i] + 1));
}
cout << ans1 << " " << ans2;
return 0;
}
标签:独木桥,洛谷,int,P1007,ans2,maxn,ans1,orz,include 来源: https://www.cnblogs.com/vv123/p/15373969.html