結果

問題 No.507 ゲーム大会(チーム決め)
ユーザー H3PO4H3PO4
提出日時 2021-07-13 21:35:46
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 566 bytes
コンパイル時間 99 ms
コンパイル使用メモリ 11,028 KB
実行使用メモリ 12,584 KB
最終ジャッジ日時 2023-09-15 13:57:50
合計ジャッジ時間 9,238 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,840 KB
testcase_01 AC 16 ms
7,744 KB
testcase_02 AC 15 ms
7,792 KB
testcase_03 AC 16 ms
7,856 KB
testcase_04 AC 15 ms
7,916 KB
testcase_05 AC 15 ms
7,868 KB
testcase_06 WA -
testcase_07 AC 792 ms
12,428 KB
testcase_08 WA -
testcase_09 AC 586 ms
11,980 KB
testcase_10 AC 594 ms
12,064 KB
testcase_11 AC 629 ms
12,072 KB
testcase_12 AC 588 ms
12,020 KB
testcase_13 AC 738 ms
12,584 KB
testcase_14 AC 724 ms
12,364 KB
testcase_15 AC 793 ms
12,420 KB
testcase_16 AC 744 ms
12,424 KB
testcase_17 AC 16 ms
7,860 KB
testcase_18 AC 16 ms
7,816 KB
testcase_19 AC 15 ms
7,784 KB
testcase_20 AC 16 ms
7,784 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, M = map(int, input().split())
A0 = int(input())
A = sorted(int(input()) for _ in range(N - 1))
l, r = 0, N - 1
while r - l > 1:
    m = (r + l) // 2
    am = A[m] + A0
    pair_l = 0
    ct = 0
    for pair_r in range(N - 2, -1, -1):
        if pair_r == m:
            continue
        while pair_l < pair_r and (A[pair_l] + A[pair_r] <= am or pair_l == m):
            pair_l += 1
        if pair_l >= pair_r:
            break
        pair_l += 1
        ct += 1
    if ct >= M:
        l = m
    else:
        r = m
ans = A[r] if r < N - 1 else -1
print(ans)
0