結果

問題 No.507 ゲーム大会(チーム決め)
ユーザー TANIGUCHI KousukeTANIGUCHI Kousuke
提出日時 2017-06-26 19:23:22
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 627 bytes
コンパイル時間 61 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 14,208 KB
最終ジャッジ日時 2024-04-15 01:54:58
合計ジャッジ時間 4,425 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 83 ms
12,288 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 162 ms
14,080 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 -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:32: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Syntax OK

ソースコード

diff #

def prize(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 = N.bsearch_index do |pair|
    if pair >= N.size
        false
    else
        prize(N[pair] + K, pair, N) > M
    end
end

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

0