結果

問題 No.27 板の準備
ユーザー letrangerjpletrangerjp
提出日時 2017-06-13 14:27:01
言語 Ruby
(3.3.0)
結果
AC  
実行時間 542 ms / 5,000 ms
コード長 284 bytes
コンパイル時間 75 ms
コンパイル使用メモリ 11,244 KB
実行使用メモリ 36,460 KB
最終ジャッジ日時 2023-08-27 04:41:56
合計ジャッジ時間 7,360 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
17,164 KB
testcase_01 AC 163 ms
21,172 KB
testcase_02 AC 339 ms
27,328 KB
testcase_03 AC 161 ms
20,704 KB
testcase_04 AC 378 ms
34,960 KB
testcase_05 AC 345 ms
29,064 KB
testcase_06 AC 457 ms
35,660 KB
testcase_07 AC 445 ms
35,604 KB
testcase_08 AC 542 ms
36,460 KB
testcase_09 AC 472 ms
35,892 KB
testcase_10 AC 402 ms
35,804 KB
testcase_11 AC 371 ms
29,844 KB
testcase_12 AC 415 ms
35,316 KB
testcase_13 AC 352 ms
29,180 KB
testcase_14 AC 297 ms
27,352 KB
testcase_15 AC 419 ms
35,556 KB
testcase_16 AC 240 ms
25,132 KB
testcase_17 AC 398 ms
30,520 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

V = gets.split.take(4).map(&:to_i)

$dp = {}
def f(v, a, b, c)
  $dp[[v,a,b,c]] ||= if v < 0
    9e9
  elsif v == 0
    0
  else
    [a, b, c].map{|d| f(v - d, a, b, c) }.min + 1
  end
end

p [*1..30].combination(3).inject(9e9){|r, (a, b, c)|
  [r, V.map{|v|f(v, a, b, c)}.sum].min
}
0