結果

問題 No.507 ゲーム大会(チーム決め)
ユーザー maspymaspy
提出日時 2020-03-03 22:03:06
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 794 bytes
コンパイル時間 456 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 20,268 KB
最終ジャッジ日時 2024-04-22 00:34:50
合計ジャッジ時間 6,438 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
10,880 KB
testcase_01 AC 32 ms
10,624 KB
testcase_02 AC 32 ms
10,624 KB
testcase_03 AC 33 ms
10,624 KB
testcase_04 AC 35 ms
10,880 KB
testcase_05 AC 31 ms
10,880 KB
testcase_06 WA -
testcase_07 AC 595 ms
20,144 KB
testcase_08 WA -
testcase_09 AC 397 ms
20,144 KB
testcase_10 AC 346 ms
19,976 KB
testcase_11 AC 296 ms
20,144 KB
testcase_12 AC 392 ms
20,020 KB
testcase_13 AC 436 ms
20,016 KB
testcase_14 AC 455 ms
20,016 KB
testcase_15 AC 437 ms
20,012 KB
testcase_16 AC 444 ms
20,016 KB
testcase_17 AC 32 ms
10,752 KB
testcase_18 AC 32 ms
10,880 KB
testcase_19 AC 31 ms
10,880 KB
testcase_20 AC 31 ms
10,752 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 = 0
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