qiuzhu
  • 板块P1007 独木桥
  • 楼主DLDZD
  • 当前回复2
  • 已保存回复2
  • 发布时间2024/11/20 19:25
  • 上次更新2024/11/20 20:56:17
查看原帖
qiuzhu
508593
DLDZD楼主2024/11/20 19:25
#include <bits/stdc++.h>
#define int long long
using namespace std;
int a[10000001];
signed main(){
	int l,n;
	cin>>l>>n;
	if(n==0){cout<<"0 0"; return 0;}
	for(int i=1;i<=n;i++) cin>>a[i];
	int minn=-1145141919;
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++) minn=max(minn,min(a[i],l+1-a[i])); cout<<minn<<" ";
	int x=a[1]+(a[n]-a[1])/2; cout<<max(l+1-x,x)+x-a[1];
    return 0;
}


2024/11/20 19:25
加载中...