結果

問題 No.156 キャンディー・ボックス
ユーザー quilt-tailsquilt-tails
提出日時 2016-10-27 18:28:10
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 352 bytes
コンパイル時間 200 ms
コンパイル使用メモリ 11,388 KB
実行使用メモリ 15,284 KB
最終ジャッジ日時 2023-08-15 20:22:31
合計ジャッジ時間 11,449 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 95 ms
15,100 KB
testcase_01 AC 82 ms
15,124 KB
testcase_02 AC 84 ms
15,260 KB
testcase_03 AC 83 ms
14,996 KB
testcase_04 AC 83 ms
15,172 KB
testcase_05 AC 149 ms
15,120 KB
testcase_06 AC 224 ms
15,124 KB
testcase_07 AC 193 ms
15,112 KB
testcase_08 AC 173 ms
15,152 KB
testcase_09 AC 149 ms
15,144 KB
testcase_10 AC 191 ms
15,256 KB
testcase_11 AC 141 ms
15,124 KB
testcase_12 AC 221 ms
15,268 KB
testcase_13 AC 172 ms
15,224 KB
testcase_14 AC 141 ms
15,272 KB
testcase_15 AC 185 ms
15,248 KB
testcase_16 AC 149 ms
15,096 KB
testcase_17 AC 174 ms
15,108 KB
testcase_18 AC 116 ms
15,132 KB
testcase_19 AC 120 ms
15,232 KB
testcase_20 AC 87 ms
15,236 KB
testcase_21 AC 92 ms
15,228 KB
testcase_22 AC 114 ms
14,988 KB
testcase_23 AC 97 ms
15,104 KB
testcase_24 AC 83 ms
15,068 KB
testcase_25 AC 83 ms
15,272 KB
testcase_26 AC 84 ms
15,124 KB
testcase_27 AC 83 ms
15,256 KB
testcase_28 AC 84 ms
15,124 KB
testcase_29 AC 83 ms
15,052 KB
testcase_30 AC 460 ms
15,080 KB
testcase_31 AC 216 ms
15,284 KB
testcase_32 TLE -
testcase_33 TLE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:1: warning: assigned but unused variable - n
Syntax OK

ソースコード

diff #

n, m = gets.split.map(&:to_i)
box = gets.split.map(&:to_i)
count = 0
empty_box = 0
while m > count
  if box.min > 0
    soe = box.index(box.min)
    unless box[soe] == 0
      box[soe] -= 1
      count += 1
    end
    if box.min == 0
      box.delete_at(box.index(box.min))
      empty_box += 1
    end
    break if count == m
  end
end
puts empty_box
0