結果

問題 No.507 ゲーム大会(チーム決め)
ユーザー vwxyzvwxyz
提出日時 2022-06-21 11:04:43
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 745 ms / 3,000 ms
コード長 685 bytes
コンパイル時間 586 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 15,516 KB
最終ジャッジ日時 2024-04-22 05:16:53
合計ジャッジ時間 8,057 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,752 KB
testcase_01 AC 28 ms
10,624 KB
testcase_02 AC 30 ms
10,624 KB
testcase_03 AC 29 ms
10,624 KB
testcase_04 AC 30 ms
10,624 KB
testcase_05 AC 30 ms
10,752 KB
testcase_06 AC 30 ms
10,624 KB
testcase_07 AC 745 ms
15,384 KB
testcase_08 AC 657 ms
15,380 KB
testcase_09 AC 436 ms
15,488 KB
testcase_10 AC 465 ms
15,488 KB
testcase_11 AC 465 ms
15,488 KB
testcase_12 AC 465 ms
15,488 KB
testcase_13 AC 601 ms
15,516 KB
testcase_14 AC 571 ms
15,384 KB
testcase_15 AC 557 ms
15,380 KB
testcase_16 AC 566 ms
15,504 KB
testcase_17 AC 30 ms
10,624 KB
testcase_18 AC 29 ms
10,624 KB
testcase_19 AC 30 ms
10,624 KB
testcase_20 AC 29 ms
10,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
readline=sys.stdin.readline

def Bisect_Int(ok,ng,is_ok):
    while abs(ok-ng)>1:
        mid=(ok+ng)//2
        if is_ok(mid):
            ok=mid
        else:
            ng=mid
    return ok

N,M=map(int,readline().split())
a=int(readline())
A=[int(readline()) for i in range(N-1)]
A.sort()
def is_ok(i):
    if i==N-1:
        return True
    AA=[A[ii] for ii in range(N-1) if i!=ii]
    cnt=0
    l,r=0,N-3
    while l<r:
        while l+1<r and AA[l]+AA[r]<=a+A[i]:
            l+=1
        if l<r and AA[l]+AA[r]>a+A[i]:
            cnt+=1
        l+=1
        r-=1
    return cnt<M
ans=Bisect_Int(N-1,-1,is_ok)
if ans==N-1:
    ans=-1
else:
    ans=A[ans]
print(ans)
0