結果

問題 No.1453 手助け
ユーザー simansiman
提出日時 2021-04-18 17:26:35
言語 Ruby
(3.3.0)
結果
AC  
実行時間 116 ms / 2,000 ms
コード長 434 bytes
コンパイル時間 168 ms
コンパイル使用メモリ 11,312 KB
実行使用メモリ 15,352 KB
最終ジャッジ日時 2023-09-17 07:49:20
合計ジャッジ時間 3,209 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
15,096 KB
testcase_01 AC 78 ms
15,212 KB
testcase_02 AC 82 ms
15,016 KB
testcase_03 AC 100 ms
15,272 KB
testcase_04 AC 79 ms
15,148 KB
testcase_05 AC 116 ms
15,252 KB
testcase_06 AC 101 ms
15,048 KB
testcase_07 AC 95 ms
15,340 KB
testcase_08 AC 79 ms
15,152 KB
testcase_09 AC 77 ms
15,324 KB
testcase_10 AC 78 ms
15,252 KB
testcase_11 AC 80 ms
15,084 KB
testcase_12 AC 78 ms
15,300 KB
testcase_13 AC 80 ms
15,036 KB
testcase_14 AC 84 ms
15,272 KB
testcase_15 AC 116 ms
15,196 KB
testcase_16 AC 84 ms
15,052 KB
testcase_17 AC 81 ms
15,352 KB
testcase_18 AC 90 ms
15,072 KB
testcase_19 AC 110 ms
15,048 KB
testcase_20 AC 92 ms
15,044 KB
testcase_21 AC 80 ms
15,308 KB
testcase_22 AC 79 ms
15,200 KB
testcase_23 AC 77 ms
15,248 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

A, B, C, D, E = gets.split.map(&:to_i)

def f(m)
  total = x = 0

  1.upto((B - C) * A) do |i|
    if i == 1
      total += (x = D)
    elsif i % 10 != 0
      total += x
    else
      if E <= x
        total += (x = [0, x - E].max)
      else
        total += x
      end
    end
  end

  total <= m
end

ok = 10 ** 18
ng = -1

while (ok - ng).abs >= 2
  x = (ok + ng) / 2

  if f(x)
    ok = x
  else
    ng = x
  end
end

puts ok
0