提交时间:2023-11-08 13:38:09

运行 ID: 109365

#include <bits/stdc++.h> using namespace std; 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 k , n , m; cin >> k >> n >> m; for(int i = 1; i <= n; i++) cin >> a[i]; a[n + 1] = l; r = l + 1; while(r - l > 1) { int mid = (r + l) / 2.0; if(check(mid)) l = mid; else r = mid; } cout << l; }