結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 82 ms
15,200 KB
testcase_04 AC 82 ms
15,276 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
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 AC 83 ms
15,180 KB
testcase_18 AC 83 ms
15,276 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 90 ms
15,300 KB
testcase_22 AC 254 ms
15,432 KB
testcase_23 AC 84 ms
15,324 KB
testcase_24 AC 83 ms
15,096 KB
testcase_25 AC 83 ms
15,040 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 862 ms
15,668 KB
testcase_30 AC 83 ms
15,172 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 TLE -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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],1]
        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,0]}
p f(a,b)||-1
0