提交时间:2023-11-11 10:57:07
运行 ID: 109811
#include <bits/stdc++.h> using namespace std; int L,n,m; int a[50005]; bool chk(int dist) { int cnt = 0,lst = 0; for (int i = 1; i <= n; i++) { if (a[i] - lst < dist) cnt++; else lst = a[i]; } if (L - lst < dist) cnt++; return cnt <= m; } int main() { cin >> L >> n >> m; for (int i = 1; i <= n; i++) cin >> a[i]; int l = 1,r = L + 1,mid; while (l + 1 < r) { mid = (l + r) / 2; if (chk(mid)) l = mid; else r = mid; } printf("%d\n",l); return 0; }