結果

問題 No.507 ゲーム大会(チーム決め)
ユーザー TANIGUCHI KousukeTANIGUCHI Kousuke
提出日時 2017-06-27 18:13:59
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 567 bytes
コンパイル時間 46 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 14,208 KB
最終ジャッジ日時 2024-04-15 02:46:13
合計ジャッジ時間 5,158 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
12,160 KB
testcase_01 WA -
testcase_02 AC 90 ms
12,288 KB
testcase_03 AC 88 ms
12,160 KB
testcase_04 AC 90 ms
12,160 KB
testcase_05 AC 95 ms
12,160 KB
testcase_06 AC 88 ms
12,288 KB
testcase_07 WA -
testcase_08 AC 283 ms
14,080 KB
testcase_09 AC 369 ms
14,208 KB
testcase_10 AC 322 ms
13,952 KB
testcase_11 AC 286 ms
14,208 KB
testcase_12 AC 368 ms
13,952 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 89 ms
12,288 KB
testcase_18 AC 87 ms
12,288 KB
testcase_19 WA -
testcase_20 AC 91 ms
12,288 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def rank(score, pair, players)
    big = players.size - 1
    count = 0
    players.each_index do |small|
        break if small >= big
        
        next if big == pair || small == pair
        
        oscore = players[big] + players[small]
        if oscore > score
            count += 1
            big -= 1
        end
    end
    count
end

n, M = gets.split.map(&:to_i)
N = n.times.map{ gets.to_i }
K = N.shift
N.sort!

min_pair = (0 .. n - 2).bsearch do |i|
    rank(K + N[i], i, N) < M
end

if min_pair.nil?
    puts - 1
else
    puts N[min_pair]
end



0