結果
問題 |
No.1453 手助け
|
ユーザー |
![]() |
提出日時 | 2021-04-18 17:26:35 |
言語 | Ruby (3.4.1) |
結果 |
AC
|
実行時間 | 127 ms / 2,000 ms |
コード長 | 434 bytes |
コンパイル時間 | 39 ms |
コンパイル使用メモリ | 7,424 KB |
実行使用メモリ | 12,288 KB |
最終ジャッジ日時 | 2024-07-04 04:39:30 |
合計ジャッジ時間 | 3,256 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
コンパイルメッセージ
Syntax OK
ソースコード
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