結果

問題 No.555 世界史のレポート
ユーザー ikdikd
提出日時 2017-08-12 01:36:11
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 481 bytes
コンパイル時間 200 ms
コンパイル使用メモリ 7,680 KB
実行使用メモリ 38,656 KB
最終ジャッジ日時 2024-04-21 00:32:22
合計ジャッジ時間 18,755 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
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
    break if dp[d]+c+r*v>=2*n
    dp[i]=[dp[i], dp[d]+c+r*v].min
  end
end

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