結果

問題 No.507 ゲーム大会(チーム決め)
ユーザー roarisroaris
提出日時 2019-11-08 15:26:07
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 695 bytes
コンパイル時間 450 ms
コンパイル使用メモリ 86,872 KB
実行使用メモリ 182,748 KB
最終ジャッジ日時 2023-10-13 03:12:24
合計ジャッジ時間 4,617 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,580 KB
testcase_01 AC 77 ms
71,360 KB
testcase_02 AC 73 ms
71,384 KB
testcase_03 AC 73 ms
71,120 KB
testcase_04 AC 75 ms
71,360 KB
testcase_05 WA -
testcase_06 AC 73 ms
71,224 KB
testcase_07 AC 197 ms
157,924 KB
testcase_08 AC 199 ms
176,128 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 207 ms
182,748 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 73 ms
71,440 KB
testcase_20 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

def judge(x):
    p = a0+a[x]
    b = [a[i] for i in range(N-1) if i != x]
    pair = 0
    l, r = 0, N-3
    
    while l <= r:
        if b[l]+b[r] >= p+1:
            pair += 1
            r -= 1
        
        l += 1
    
    return pair <= M-1
    
def binary_search():
    left, right = 0, N-2
    
    while left <= right:
        mid = (left+right)//2
        
        if judge(mid):
            right = mid-1
        else:
            left = mid+1
    
    return left

N, M = map(int, input().split())
a0 = int(input())
a = [int(input()) for _ in range(N-1)]
a.sort()

idx = binary_search()

if idx == N-1:
    print(-1)
else:
    print(a[idx])
0