我的逻辑很简单,就是枚举相邻最大距离,check一下判断需要插入的路标数量
#include <iostream>
using namespace std;
const int N = 1e5 + 2;
int l, n, k, a[N];
int check(int x){
int cnt = 0;
for(int i = 1, last = 0; i < n; i++){
if(last) continue;
cnt += (a[i] - a[i - 1]) % x;
last = i;
}
return cnt;
}
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) >= k) t = mid;
else s = mid;
}
cout << t;
return 0;
}