結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
12,160 KB
testcase_01 WA -
testcase_02 RE -
testcase_03 AC 84 ms
12,288 KB
testcase_04 AC 83 ms
12,160 KB
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 RE -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:29: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Syntax OK

ソースコード

diff #

def ok(score, pair)
    head = N.size - 1
    count = 0
    N.each_index.inject(head) do |big, small|
        break unless big > small
        next big if big == pair || small == pair
        
        oscore = N[big] + N[small]
        if oscore > score
            count += 1
            big - 1
        else
           big
        end
    end
    count < M
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|
    ok(N[pair] + K, pair)
end

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

0