結果

問題 No.507 ゲーム大会(チーム決め)
ユーザー maspymaspy
提出日時 2020-03-03 22:13:44
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 405 ms / 3,000 ms
コード長 795 bytes
コンパイル時間 208 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 20,140 KB
最終ジャッジ日時 2024-04-22 00:38:38
合計ジャッジ時間 4,492 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
10,624 KB
testcase_01 AC 27 ms
10,624 KB
testcase_02 AC 28 ms
10,752 KB
testcase_03 AC 27 ms
10,624 KB
testcase_04 AC 26 ms
10,496 KB
testcase_05 AC 27 ms
10,624 KB
testcase_06 AC 27 ms
10,624 KB
testcase_07 AC 405 ms
20,140 KB
testcase_08 AC 290 ms
19,888 KB
testcase_09 AC 344 ms
20,012 KB
testcase_10 AC 306 ms
19,760 KB
testcase_11 AC 265 ms
20,128 KB
testcase_12 AC 340 ms
20,016 KB
testcase_13 AC 303 ms
19,884 KB
testcase_14 AC 313 ms
19,892 KB
testcase_15 AC 309 ms
19,884 KB
testcase_16 AC 305 ms
19,888 KB
testcase_17 AC 26 ms
10,496 KB
testcase_18 AC 26 ms
10,880 KB
testcase_19 AC 27 ms
10,624 KB
testcase_20 AC 25 ms
10,496 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
# %%
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from collections import deque

# %%
N, M, *A = map(int, read().split())

# %%
me = A[0]
A = sorted(A[1:])


# %%
def can_win(n):
    # n番目の人と組んだ場合の結果
    B = A[:]
    team_pt = B[n] + me
    del B[n]
    B = deque(B)
    pair_cnt = 0
    while len(B) >= 2:
        if B[0] + B[-1] > team_pt:
            pair_cnt += 1
            B.popleft()
            B.pop()
        else:
            B.popleft()
    return pair_cnt <= M - 1


# %%
left = -1
right = N - 1
while left + 1 < right:
    x = (left + right) // 2
    if can_win(x):
        right = x
    else:
        left = x


# %%
print(-1 if right == N - 1 else A[right])
0