結果

問題 No.507 ゲーム大会(チーム決め)
ユーザー tktk_snsntktk_snsn
提出日時 2021-01-25 09:48:23
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 147 ms / 3,000 ms
コード長 694 bytes
コンパイル時間 1,975 ms
コンパイル使用メモリ 87,044 KB
実行使用メモリ 82,932 KB
最終ジャッジ日時 2023-09-03 20:21:41
合計ジャッジ時間 5,374 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
71,612 KB
testcase_01 AC 78 ms
71,528 KB
testcase_02 AC 79 ms
71,532 KB
testcase_03 AC 81 ms
71,544 KB
testcase_04 AC 82 ms
71,360 KB
testcase_05 AC 82 ms
71,540 KB
testcase_06 AC 80 ms
71,760 KB
testcase_07 AC 147 ms
82,512 KB
testcase_08 AC 135 ms
79,980 KB
testcase_09 AC 124 ms
81,372 KB
testcase_10 AC 126 ms
79,844 KB
testcase_11 AC 130 ms
82,932 KB
testcase_12 AC 126 ms
80,980 KB
testcase_13 AC 142 ms
80,956 KB
testcase_14 AC 143 ms
81,800 KB
testcase_15 AC 145 ms
81,172 KB
testcase_16 AC 137 ms
81,064 KB
testcase_17 AC 80 ms
71,636 KB
testcase_18 AC 78 ms
71,544 KB
testcase_19 AC 77 ms
71,648 KB
testcase_20 AC 78 ms
71,364 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

N, M = map(int, input().split())
A = int(input())
B = [int(input()) for _ in range(N - 1)]
B.sort()


def F(x):
    C = deque()
    for i, b in enumerate(B):
        if i == x:
            continue
        C.append(b)

    score = A + B[x]
    cnt = 0
    while C:
        R = C.pop()
        while C:
            L = C.popleft()
            if R + L > score:
                cnt += 1
                break
    return cnt >= M


l = -1
r = N-1
while (r - l) > 1:
    m = (r + l) // 2
    if F(m):
        l = m
    else:
        r = m


if r == N - 1:
    print(-1)
else:
    print(B[r])
0