描述
自己网上找…
代码
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
long long l,d[50010];
int m,n,pre[50010],bak[50010];
bool vis[50010];
int main(){
freopen("stone.in","r",stdin);
freopen("stone.out","r",stdout);
scanf("%lld%d%d",&l,&n,&m);
d[0]=0;
for(int i=1;i<=n;i++) scanf("%lld",&d[i]);
for(int i=1;i<=n;i++) pre[i]=i-1;
memcpy(bak,pre,sizeof(pre));
long long left=0,right=l;
long long mid;
int t=100;
while(t--){
memset(vis,0,sizeof(vis));
memcpy(pre,bak,sizeof(bak));
int cnt=0; bool flag=1;
mid=(left+right)/2;
for(int i=1;i<=n;i++){
if(!vis[i]&&d[i]-d[pre[i]]<mid){
vis[i]=1;
pre[i+1]=pre[i];
cnt++;
}
if(cnt>m) {
flag=0; break;
}
}
if(flag) left=mid+1;
else right=mid-1;
}
printf("%lld",mid);
return 0;
}