【题解】P1007 独木桥
题面
前言
好诈骗……
正文
众所周知,我们并不关心他们离开的顺序
换言之,士兵之间没有差别
所以,两个人相遇同时掉头等价于交换灵魂继续前进!
所以最大值与最小值将会非常明显……
代码
#include<iostream>
using namespace std;
int n,l,ans1,ans2;
int main(){
cin>>l>>n;
for(int i=1;i<=n;i++){
int x;
cin>>x;
ans1=max(min(l+1-x,x),ans1);
ans2=max(max(l+1-x,x),ans2);
}
cout<<ans1<<' '<<ans2<<endl;
return 0;
}
后记
试图水过这篇题解……
完结撒花!