結果

問題 No.50 おもちゃ箱
ユーザー gigurururugigurururu
提出日時 2014-11-07 14:10:13
言語 Ruby
(3.3.0)
結果
RE  
実行時間 -
コード長 356 bytes
コンパイル時間 74 ms
コンパイル使用メモリ 11,332 KB
実行使用メモリ 17,096 KB
最終ジャッジ日時 2023-08-30 01:50:51
合計ジャッジ時間 5,979 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 AC 84 ms
15,100 KB
testcase_04 AC 83 ms
15,036 KB
testcase_05 AC 98 ms
15,492 KB
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 AC 82 ms
15,172 KB
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 AC 83 ms
15,140 KB
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 AC 83 ms
15,172 KB
testcase_24 AC 81 ms
15,148 KB
testcase_25 AC 82 ms
15,104 KB
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 AC 82 ms
15,240 KB
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
testcase_40 AC 198 ms
17,096 KB
testcase_41 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

$h={}
def f a,b
  $h[a+b.sort]||=(if a[0]
    (0..b.size-1).map{|i|
      c=b.dup
      n,_=c[i]
      if n>=a[0]
        c[i]=[n-a[0],true]
        f(a[1..-1],c)
      else
        nil
      end
    }.compact.min
  else
    b.count{|i,j|j}
  end)
end
gets
a=gets.split.map(&:to_i)
gets
b=gets.split.map{|c|[c.to_i,false]}
p f(a,b)||-1
0