結果

問題 No.555 世界史のレポート
ユーザー ikdikd
提出日時 2017-08-12 01:30:14
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 451 bytes
コンパイル時間 46 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 36,608 KB
最終ジャッジ日時 2024-04-21 00:31:45
合計ジャッジ時間 19,611 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 89 ms
12,032 KB
testcase_01 AC 89 ms
12,032 KB
testcase_02 AC 89 ms
12,160 KB
testcase_03 AC 90 ms
12,288 KB
testcase_04 AC 93 ms
12,288 KB
testcase_05 AC 98 ms
12,288 KB
testcase_06 AC 97 ms
12,160 KB
testcase_07 AC 98 ms
12,160 KB
testcase_08 AC 101 ms
12,288 KB
testcase_09 AC 103 ms
12,288 KB
testcase_10 AC 1,604 ms
29,184 KB
testcase_11 AC 1,850 ms
31,616 KB
testcase_12 AC 1,584 ms
29,056 KB
testcase_13 AC 1,341 ms
26,880 KB
testcase_14 AC 1,766 ms
31,104 KB
testcase_15 AC 1,834 ms
31,360 KB
testcase_16 AC 1,487 ms
27,904 KB
testcase_17 AC 1,688 ms
30,208 KB
testcase_18 AC 1,867 ms
31,744 KB
testcase_19 TLE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n=gets.to_i
c, v=gets.split.map(&:to_i)

def f(n)
  rt=[]
  (1..n).each do |i|
    break if i*i>n
    if n%i==0
      rt<< i
      rt<< n/i
    end
  end
  rt
end

def g(n)
  rt=Array.new(n+1)
  (1..n).each do |e|
    rt[e]=f(e)
  end
  rt
end

dd=g(2*n)
inf=10**9
dp=Array.new(2*n){inf}
dp[0]=dp[1]=0
r=nil
(2...(2*n)).each do |i|
  # dd=f(i)
  dd[i].each do |d|
    r=(i-d+d-1)/d
    dp[i]=[dp[i], dp[d]+c+r*v].min
  end
end

puts dp[n...(2*n)].min
0