提交时间:2024-01-25 08:44:03

运行 ID: 127333

#include<bits/stdc++.h> using namespace std; typedef long long ll; int n; int m; int k; int a[50010]; int l; int r; int mid; bool check(int x) { int now=0; int sum=0; for(int i=1;i<=n+1;i++) { if(a[i]-a[now]<x) { sum++; } else { now=i; } } return sum<=k; } int main() { //freopen("","r",stdin); //freopen("","w",stdout); ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>m; cin>>n; cin>>k; for(int i=1;i<=n;i++) { cin>>a[i]; } a[n+1]=m; l=1; r=m; while(l<r) { mid=(l+r+1)>>1; if(check(mid)==1) { l=mid; } else { r=mid-1; } } cout<<l; //fclose(stdin); //fclose(stdout); return 0; }