結果

問題 No.555 世界史のレポート
ユーザー cympfhcympfh
提出日時 2017-08-25 18:45:51
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 362 bytes
コンパイル時間 62 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 12,544 KB
最終ジャッジ日時 2024-04-23 15:20:30
合計ジャッジ時間 3,478 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
12,160 KB
testcase_01 AC 87 ms
12,032 KB
testcase_02 AC 87 ms
12,160 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 89 ms
12,288 KB
testcase_09 AC 89 ms
12,416 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 180 ms
12,288 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

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

ans = nil

n.times do |i|
  a, b, cost = 1, 0, 0
  (i + 1).times do # c+v
    a, b, cost = 2 * a, a, cost + c + v
    # p ['c+v =>', a, b, cost]
    break if a >= n
  end
  while a < n  # v
    a, b, cost = a + b, b, cost + v
    # p ['v =>', a, b, cost]
  end

  ans = ans == nil ? cost : [ans, cost].min
end

p ans
0