1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| #include<bits/stdc++.h> using namespace std;
const int N=50010; int shitou[N]; int l,n,m; bool check(int mid) { int use=0; int first=0; for(int i=1;i<=n;i++) { if(shitou[i]-first<mid) { use++; } else first=shitou[i];
}
return use<=m;
}
int main() { cin>>l>>n>>m ; for(int i=1;i<=n;i++) { cin>>shitou[i]; } shitou[++n]=l; int l=0;int r=1e9+10; while(l<r) { int mid=l+r+1>>1; if(check(mid)) l=mid; else r=mid-1;
}
cout<<r;
}
|