結果

問題 No.555 世界史のレポート
ユーザー simansiman
提出日時 2021-09-16 13:39:00
言語 Ruby
(3.3.0)
結果
AC  
実行時間 188 ms / 2,000 ms
コード長 278 bytes
コンパイル時間 336 ms
コンパイル使用メモリ 11,436 KB
実行使用メモリ 15,736 KB
最終ジャッジ日時 2023-09-12 01:18:41
合計ジャッジ時間 4,718 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
15,040 KB
testcase_01 AC 85 ms
15,132 KB
testcase_02 AC 84 ms
15,176 KB
testcase_03 AC 85 ms
15,072 KB
testcase_04 AC 85 ms
15,076 KB
testcase_05 AC 86 ms
15,236 KB
testcase_06 AC 85 ms
15,280 KB
testcase_07 AC 86 ms
15,160 KB
testcase_08 AC 86 ms
15,080 KB
testcase_09 AC 86 ms
15,036 KB
testcase_10 AC 156 ms
15,528 KB
testcase_11 AC 165 ms
15,704 KB
testcase_12 AC 155 ms
15,516 KB
testcase_13 AC 146 ms
15,516 KB
testcase_14 AC 162 ms
15,440 KB
testcase_15 AC 164 ms
15,504 KB
testcase_16 AC 153 ms
15,636 KB
testcase_17 AC 159 ms
15,736 KB
testcase_18 AC 165 ms
15,444 KB
testcase_19 AC 188 ms
15,672 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N = gets.to_i
C, V = gets.split.map(&:to_i)

dp = Array.new(N + 1, Float::INFINITY)
dp[1] = 0

1.upto(N - 1) do |i|
  1.upto(Rational(N - i, i).ceil) do |j|
    n = i + i * j
    n = N if n > N
    cost = dp[i] + C + j * V
    dp[n] = cost if dp[n] > cost
  end
end

puts dp[N]
0