結果

問題 No.507 ゲーム大会(チーム決め)
ユーザー titiatitia
提出日時 2023-09-30 00:27:55
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 573 bytes
コンパイル時間 722 ms
コンパイル使用メモリ 10,764 KB
実行使用メモリ 15,272 KB
最終ジャッジ日時 2023-09-30 00:28:29
合計ジャッジ時間 9,600 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,756 KB
testcase_01 AC 14 ms
7,788 KB
testcase_02 AC 15 ms
7,908 KB
testcase_03 AC 15 ms
7,848 KB
testcase_04 AC 15 ms
7,812 KB
testcase_05 AC 14 ms
7,812 KB
testcase_06 AC 15 ms
7,832 KB
testcase_07 AC 868 ms
15,128 KB
testcase_08 AC 727 ms
15,056 KB
testcase_09 AC 745 ms
15,200 KB
testcase_10 AC 708 ms
15,180 KB
testcase_11 AC 736 ms
15,080 KB
testcase_12 AC 810 ms
15,116 KB
testcase_13 AC 820 ms
15,092 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N,M=map(int,input().split())
A=[int(input()) for i in range(N)]

K=A[0]
B=A[1:]

B.sort()

OK=len(B)
NG=-1

while OK>NG+1:
    mid=(OK+NG)//2

    now=K+B[mid]
    C=B[:now]+B[now+1:]

    ind=0
    member=0
    for i in range(len(C)-1,-1,-1):
        while ind<i and C[ind]+C[i]<=now:
            ind+=1

        if ind<i and C[ind]+C[i]>now:
            member+=1
            ind+=1

    #print(mid,now,member)

    if member<M:
        OK=mid
    else:
        NG=mid

if OK==len(B):
    print(-1)
else:
    print(B[OK])
    
    
0