結果

問題 No.27 板の準備
ユーザー finefine
提出日時 2017-01-09 19:10:36
言語 Ruby
(3.3.0)
結果
AC  
実行時間 122 ms / 5,000 ms
コード長 539 bytes
コンパイル時間 58 ms
コンパイル使用メモリ 11,304 KB
実行使用メモリ 16,292 KB
最終ジャッジ日時 2023-08-27 04:37:54
合計ジャッジ時間 2,950 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
15,080 KB
testcase_01 AC 78 ms
15,036 KB
testcase_02 AC 77 ms
15,060 KB
testcase_03 AC 74 ms
15,244 KB
testcase_04 AC 116 ms
16,024 KB
testcase_05 AC 118 ms
16,236 KB
testcase_06 AC 118 ms
16,080 KB
testcase_07 AC 116 ms
15,972 KB
testcase_08 AC 118 ms
15,972 KB
testcase_09 AC 119 ms
16,292 KB
testcase_10 AC 122 ms
15,988 KB
testcase_11 AC 120 ms
15,864 KB
testcase_12 AC 119 ms
16,060 KB
testcase_13 AC 119 ms
15,968 KB
testcase_14 AC 122 ms
16,068 KB
testcase_15 AC 117 ms
16,056 KB
testcase_16 AC 118 ms
15,968 KB
testcase_17 AC 116 ms
16,024 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

v = gets.split.map(&:to_i).uniq.sort
if v.size != 4
    p 4
    exit
end
ans = 1000
3.upto(30) do |c|  
    2.upto(c - 1) do |b|
        1.upto(b - 1) do |a|
            dp = Array.new(31, 1000)
            dp[0] = 0
            [a, b, c].each do |x|
                1.upto(30) do |i|
                    dp[i] = [dp[i], dp[i - x] + 1].min if i >= x
                end
            end
            tmp = 0
            v.each do |x|
                tmp += dp[x]
            end
            ans = [ans, tmp].min
        end
    end
end
p ans
0