// yukicoder: No.507 ゲーム大会(チーム決め) // bal4u 2019.8.20 #include #include //// 入出力関係 #if 1 #define gc() getchar_unlocked() #else #define gc() getchar() #endif int in() { // 非負整数の入力 int n = 0, c = gc(); do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0'); return n; } int N, M; int a[100005]; int cmp(const void *u, const void *v) { return *(int *)u - *(int *)v; } int ok(int x, int id) { int i, j, n = 0; j = N-1; for (i = 1; i < j; i++) { if (j == id) j--; while (i < j && (i == id || a[i] + a[j] < x)) i++; if (i < j) { if (++n >= M) return 0; } j--; } return 1; } int resolv() { int t, f = 0, m, l = 1, r = N; while (l+1 < r) { m = (l+r) >> 1; t = ok(a[0]+a[m], m), f |= t; if (t) r = m; else l = m; } if (!f) return -1; return a[r]; } int main() { int i; N = in(), M = in(); for (i = 0; i < N; i++) a[i] = in(); if (N == 2) { printf("%d\n", a[1]); return 0; } qsort(a+1, N-1, sizeof(int), cmp); a[0]++; printf("%d\n", resolv()); return 0; }