#include <cstdio>
#include <cstring>
using namespace std;
const int maxn=50005;
int a[maxn],n,m,ans;
bool check(int x)
{
int sum,last;
sum=0;last=0;
for (int i=1;i<=n;i++)
{
if (a[i]-last<x) { sum+=1;continue;}
last=a[i];
}
if (sum>m) return 0;
return 1;
}
int main()
{
int L,R,mid;
scanf("%d%d%d\n",&L,&n,&m);
for (int i=1;i<=n;i++) scanf("%d\n",&a[i]);
n+=1;
a[n]=L;R=L;
ans=L=0;
while (L<=R)
{
mid=L+(R-L)/2;
if (check(mid)) { ans=mid;L=mid+1; }
else R=mid-1;
}
printf("%d",ans);
return 0;
}
原文:http://www.cnblogs.com/DZRDerek/p/5971373.html