计网的烦恼

#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
const int maxn=100007;
const double eps=1e-10;
int n,m;
int h[maxn];
double left=0.0,right=10000000.0,mid;
void judge{
    double sum=h[0]+2*mid;
    int cnt=1;
    for(int i=1;i<n;i++){
        if(sum<h[i]){
            sum=h[i]+2*mid;
            cnt++;
        }
    }
    if(cnt>m)
        left=mid;
    else
        right=mid;

}
int main()
{
    while(~scanf())
    scanf("%d%d",&m,&n);
    for(int i=0;i<n;i++){
        scanf("%d",&h[i]);
    }
    sort(h,h+n);

    while(right-left>=eps){
        judge(mid);

    }
    printf("%.1f\n",mid);
}

猜你喜欢

转载自www.cnblogs.com/loganlzj/p/10181137.html
今日推荐