#include #include #include using namespace std; int N, L; int K; vector a; bool check(int x) { // dp[j][i]... maximum number of intervals taken so far, // guaranteeing at least j intervals of length >= x, // currently focusing on the i-th cut point vector> dp(4, vector(N + 2, -1)); dp[0][0] = 0; for (int j = 0; j < 3; j++) { for (int i = 0; i <= N; i++) { if (dp[j][i] == -1) continue; // take the next interval immediately dp[j][i + 1] = max(dp[j][i + 1], dp[j][i] + 1); // jump to the interval where length >= x int idx = (int)(lower_bound(a.begin(), a.end(), a[i] + x) - a.begin()); if (idx >= (int)a.size()) continue; dp[j + 1][idx] = max(dp[j + 1][idx], dp[j][i] + 1); } } return dp[2][N + 1] >= K + 1; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin >> N >> L; cin >> K; a.resize(N + 2); a[0] = 0; for (int i = 1; i <= N; i++) { cin >> a[i]; } a[N + 1] = L; int ng = 1; int ok = L + 1; while (ok - ng > 1) { int mid = (ok + ng) / 2; if (check(mid)) { ng = mid; } else { ok = mid; } } cout << ng << "\n"; return 0; }