提交时间:2023-11-08 13:43:04
运行 ID: 109385
#include <bits/stdc++.h> using namespace std; int k , n , m; int a[100005]; bool check(int x) { int p = a[0]; int sum = 0; for(int i = 1; i <= n + 1; i++) { if(a[i] - p < x) sum++; else p = a[i]; } return sum <= m; } int main() { int l , r; cin >> k >> n >> m; for(int i = 1; i <= n; i++) cin >> a[i]; a[n + 1] = k; r = k + 1; while(r - l > 1) { int mid = (r + l) / 2.0; if(check(mid)) l = mid; else r = mid; } cout << l; }