結果

問題 No.507 ゲーム大会(チーム決め)
ユーザー vwxyzvwxyz
提出日時 2022-06-21 11:01:47
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 659 bytes
コンパイル時間 2,311 ms
コンパイル使用メモリ 10,888 KB
実行使用メモリ 12,936 KB
最終ジャッジ日時 2023-08-04 07:19:13
合計ジャッジ時間 8,409 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,944 KB
testcase_01 AC 16 ms
7,952 KB
testcase_02 WA -
testcase_03 AC 16 ms
7,832 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 698 ms
12,844 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
権限があれば一括ダウンロードができます

ソースコード

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-2
    while l<r:
        while l+1<r and A[l]+A[r]<=a+A[i]:
            l+=1
        if l<r and A[l]+A[r]>a+A[i]:
            cnt+=1
        l+=1
        r-=1
    return cnt<M
ans=Bisect_Int(N-1,0,is_ok)
if ans==N-1:
    ans=-1
print(ans)
0