@[thehanged](/user/638272) 原来是check函数的问题
ac代码
```cpp
#include <iostream>
using namespace std;
const int N = 1e5 + 2;
int l, n, k, a[N];
int check(int x){
int cnt = k, pos = a[0];
for(int i = 1; i < n; i++){
if(cnt < 0) return -1;
if(a[i] - pos <= x) pos = a[i];
else{
i --;
cnt --; //分配路标
pos += x;
}
}
return cnt >= 0 ? 1 : -1;
}
int main(){
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cin >> l >> n >> k;
for(int i = 0; i < n; i++) cin >> a[i];
int s = 0, t = l;
while(s + 1 != t){
int mid = (s + t) / 2;
if(check(mid) != -1) t = mid;
else s = mid;
}
cout << t;
return 0;
}
```
by thehanged @ 2024-01-28 13:43:11