提交时间:2023-11-08 18:56:03
运行 ID: 109451
#include <bits/stdc++.h> using namespace std; int a[500010]; int d , n , m; bool two_find(int x) { int tot = 0; int i = 0; int now = 0; while (i < n + 1) { i++; if (a[i] - a[now] < x) tot++; else now = i; } if (tot > m) return false; else return true; } int main() { cin >> d >> n >> m; int cnt = 0; for (int i = 1;i <= n;i++) cin >> a[i]; int l , r , mid; a[n + 1] = d; l = 1; r = d; while (l <= r) { mid = (l + r) / 2; if (two_find(mid)) { cnt = mid; l = mid + 1; } else r = mid - 1; } cout << cnt << endl; return 0; }