結果
| 問題 | No.507 ゲーム大会(チーム決め) | 
| コンテスト | |
| ユーザー |  maspy | 
| 提出日時 | 2020-03-03 22:13:44 | 
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 497 ms / 3,000 ms | 
| コード長 | 795 bytes | 
| コンパイル時間 | 114 ms | 
| コンパイル使用メモリ | 12,672 KB | 
| 実行使用メモリ | 20,144 KB | 
| 最終ジャッジ日時 | 2024-10-13 23:11:18 | 
| 合計ジャッジ時間 | 5,407 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 19 | 
ソースコード
#!/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])
            
            
            
        