結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
12,160 KB
testcase_01 RE -
testcase_02 AC 76 ms
12,288 KB
testcase_03 AC 76 ms
12,160 KB
testcase_04 AC 75 ms
12,288 KB
testcase_05 AC 78 ms
12,160 KB
testcase_06 AC 76 ms
12,160 KB
testcase_07 RE -
testcase_08 AC 255 ms
13,952 KB
testcase_09 AC 330 ms
14,080 KB
testcase_10 AC 294 ms
14,080 KB
testcase_11 AC 257 ms
13,952 KB
testcase_12 AC 324 ms
13,952 KB
testcase_13 AC 261 ms
13,952 KB
testcase_14 AC 274 ms
14,080 KB
testcase_15 AC 274 ms
14,080 KB
testcase_16 AC 262 ms
13,952 KB
testcase_17 AC 75 ms
12,288 KB
testcase_18 AC 77 ms
12,160 KB
testcase_19 AC 77 ms
12,160 KB
testcase_20 AC 76 ms
12,160 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def rank(score, pair, players)
    big = players.size - 1
    count = 0
    players.each_index do |small|
        break if small >= big
        
        if big == pair 
            big -= 1
            redo
        elsif small == pair
            next
        end
        
        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