/* -*- coding: utf-8 -*- * * 3513.cc: No.3513 Greedy Yokan Party - yukicoder */ #include #include using namespace std; /* constant */ const int MAX_N = 200000; /* typedef */ /* global variables */ int as[MAX_N + 2]; int dp[MAX_N + 2][3]; /* subroutines */ void setmax(int &a, int b) { if (a < b) a = b; } int calc(int n, int x) { for (int i = 0; i <= n; i++) fill(dp[i], dp[i] + 3, -1); dp[0][0] = 0; for (int i = 0, i1 = 0; i < n; i++) { while (i1 < n && as[i1] - as[i] < x) i1++; for (int j = 0; j <= 2; j++) if (dp[i][j] >= 0) { setmax(dp[i + 1][j], dp[i][j] + 1); if (j < 2 && as[i1] - as[i] >= x) setmax(dp[i1][j + 1], dp[i][j] + 1); } } return dp[n][2]; } /* main */ int main() { int n, l, k; scanf("%d%d%d", &n, &l, &k); as[0] = 0, as[n + 1] = l; for (int i = 1; i <= n; i++) scanf("%d", as + i); n++; int x0 = 0, x1 = l; while (x0 + 1 < x1) { int x = (x0 + x1) / 2; if (calc(n, x) > k) x0 = x; else x1 = x; } printf("%d\n", x0); return 0; }