結果

問題 No.198 キャンディー・ボックス2
ユーザー fine
提出日時 2016-01-11 00:42:01
言語 Ruby
(3.4.1)
結果
WA  
実行時間 -
コード長 284 bytes
コンパイル時間 43 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 12,288 KB
最終ジャッジ日時 2024-09-19 18:41:11
合計ジャッジ時間 3,264 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 22 WA * 4
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:2: warning: assigned but unused variable - n
Syntax OK

ソースコード

diff #

b = gets.to_i
n = gets.to_i
c = STDIN.map(&:to_i)
c_uniq = c.uniq
ans = []
c_uniq.each{|standard|
    give = b
    sum = 0
    c.each{|candy|
        tmp = candy - standard
        give += tmp
        sum += tmp.abs
    }
    if give >= 0
        ans.push(sum)
    end
    }
p ans.min
0