結果

問題 No.555 世界史のレポート
ユーザー yuruhiyayuruhiya
提出日時 2020-07-21 17:30:08
言語 Crystal
(1.11.2)
結果
AC  
実行時間 83 ms / 2,000 ms
コード長 378 bytes
コンパイル時間 21,009 ms
コンパイル使用メモリ 254,784 KB
実行使用メモリ 22,628 KB
最終ジャッジ日時 2023-09-13 11:16:23
合計ジャッジ時間 18,408 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,396 KB
testcase_01 AC 2 ms
4,424 KB
testcase_02 AC 3 ms
4,472 KB
testcase_03 AC 3 ms
4,540 KB
testcase_04 AC 2 ms
4,488 KB
testcase_05 AC 3 ms
4,584 KB
testcase_06 AC 3 ms
4,596 KB
testcase_07 AC 3 ms
4,628 KB
testcase_08 AC 3 ms
4,660 KB
testcase_09 AC 4 ms
4,788 KB
testcase_10 AC 60 ms
16,860 KB
testcase_11 AC 65 ms
19,500 KB
testcase_12 AC 56 ms
16,832 KB
testcase_13 AC 47 ms
14,580 KB
testcase_14 AC 61 ms
17,628 KB
testcase_15 AC 64 ms
18,104 KB
testcase_16 AC 51 ms
16,164 KB
testcase_17 AC 60 ms
17,468 KB
testcase_18 AC 66 ms
19,864 KB
testcase_19 AC 83 ms
22,628 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = read_line.to_i
c, v = read_line.split.map &.to_i
dp = Array.new(n + 1) { Hash(Int32, Int32).new(10 ** 9) }
dp[2][1] = c + v

(2...n).each do |len|
  dp[len].each do |clip, cost|
    dp[{len + clip, n}.min][clip] = {cost + v, dp[{len + clip, n}.min][clip]}.min
    dp[{len + len, n}.min][len] = {cost + c + v, dp[{len + len, n}.min][len]}.min
  end
end
puts dp[n].values.min
0