結果

問題 No.740 幻の木
ユーザー Takuya NoguchiTakuya Noguchi
提出日時 2018-10-14 10:52:27
言語 Ruby
(3.3.0)
結果
AC  
実行時間 188 ms / 2,000 ms
コード長 339 bytes
コンパイル時間 138 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 12,288 KB
最終ジャッジ日時 2024-04-20 20:15:52
合計ジャッジ時間 1,595 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 89 ms
12,160 KB
testcase_01 AC 86 ms
12,032 KB
testcase_02 AC 89 ms
12,288 KB
testcase_03 AC 93 ms
12,288 KB
testcase_04 AC 84 ms
12,160 KB
testcase_05 AC 87 ms
12,288 KB
testcase_06 AC 188 ms
12,160 KB
testcase_07 AC 87 ms
12,160 KB
testcase_08 AC 85 ms
12,032 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n, M, P, Q = gets.split.map(&:to_i)

fail_leaves = {}
(1..12).each do |m|
  fail_leaves[m] = M
  if m.between?(P, P + Q - 1) || (m + 12).between?(P, P + Q - 1)
    fail_leaves[m] += M
  end
end

answer, month = 0, 1
loop do
  answer += 1
  n -= fail_leaves[month]

  break if n <= 0

  month += 1
  month = 1 if month > 12
end

puts answer
0