結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
12,288 KB
testcase_01 AC 87 ms
12,160 KB
testcase_02 AC 81 ms
12,288 KB
testcase_03 AC 82 ms
12,288 KB
testcase_04 AC 83 ms
12,288 KB
testcase_05 AC 85 ms
12,160 KB
testcase_06 AC 89 ms
12,288 KB
testcase_07 AC 86 ms
12,288 KB
testcase_08 AC 88 ms
12,288 KB
testcase_09 AC 93 ms
12,288 KB
testcase_10 AC 1,407 ms
12,544 KB
testcase_11 AC 1,644 ms
12,800 KB
testcase_12 AC 1,438 ms
12,800 KB
testcase_13 AC 1,177 ms
12,416 KB
testcase_14 AC 1,558 ms
12,928 KB
testcase_15 AC 1,609 ms
12,800 KB
testcase_16 AC 1,313 ms
12,800 KB
testcase_17 AC 1,482 ms
12,800 KB
testcase_18 AC 1,644 ms
12,800 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

inf=10**18
dp=Array.new(2*n){inf}
dp[0]=dp[1]=0
(2...(2*n)).each do |i|
  # dd=f(i)
  (1..i).each do |dd|
    # r=(i-d+d-1)/d
    # dp[i]=[dp[i], dp[d]+c+r*v].min
    break if dd*dd>i
    next if i%dd!=0
    d=i/dd
    dp[i]=[dp[i], dp[d]+c+(i-1)/d*v].min
    if d!=dd
      dp[i]=[dp[i], dp[dd]+c+(i-1)/dd*v].min
    end
  end
end

puts dp[n...(2*n)].min
=begin

  L+l*cn>=LL, cn>=(LL-L)/l ... V*cn
  L+L*cm>=LL, cm>=(LL-L)/L ... V*cm+C

=end
0