結果

問題 No.507 ゲーム大会(チーム決め)
ユーザー H3PO4H3PO4
提出日時 2021-07-13 21:46:02
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 800 ms / 3,000 ms
コード長 567 bytes
コンパイル時間 140 ms
コンパイル使用メモリ 10,820 KB
実行使用メモリ 12,464 KB
最終ジャッジ日時 2023-09-15 14:10:10
合計ジャッジ時間 8,501 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,812 KB
testcase_01 AC 16 ms
7,788 KB
testcase_02 AC 16 ms
7,800 KB
testcase_03 AC 16 ms
7,880 KB
testcase_04 AC 15 ms
7,792 KB
testcase_05 AC 16 ms
7,940 KB
testcase_06 AC 15 ms
7,876 KB
testcase_07 AC 800 ms
12,400 KB
testcase_08 AC 729 ms
12,448 KB
testcase_09 AC 573 ms
12,036 KB
testcase_10 AC 603 ms
11,992 KB
testcase_11 AC 603 ms
12,164 KB
testcase_12 AC 605 ms
12,104 KB
testcase_13 AC 772 ms
12,464 KB
testcase_14 AC 754 ms
12,460 KB
testcase_15 AC 757 ms
12,388 KB
testcase_16 AC 757 ms
12,392 KB
testcase_17 AC 15 ms
7,772 KB
testcase_18 AC 16 ms
7,776 KB
testcase_19 AC 16 ms
7,884 KB
testcase_20 AC 16 ms
7,772 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, M = map(int, input().split())
A0 = int(input())
A = sorted(int(input()) for _ in range(N - 1))
l, r = -1, 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