提交时间:2024-04-10 13:50:38
运行 ID: 142871
#include<bits/stdc++.h> using namespace std; int a[114514],l,n,m,lb,ub; bool check(int x){ int p=a[0],sum=0; for(int i=1;i<=n+1;i++){ if(a[i]-p<x)sum++; else p=a[i]; } return sum<=m; } int main(){ cin>>l>>n>>m; for(int i=1;i<=n;i++)cin>>a[i]; a[n+1]=l; int ub=l+1; while(ub-lb>1){ int mid=(ub+lb)/2.0; if(check(mid))lb=mid; else ub=mid; } cout<<lb; return 0; }