結果
問題 | No.740 幻の木 |
ユーザー |
![]() |
提出日時 | 2025-03-26 15:47:36 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 43 ms / 2,000 ms |
コード長 | 1,386 bytes |
コンパイル時間 | 217 ms |
コンパイル使用メモリ | 82,516 KB |
実行使用メモリ | 59,820 KB |
最終ジャッジ日時 | 2025-03-26 15:48:43 |
合計ジャッジ時間 | 1,170 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 6 |
ソースコード
N, M, P, Q = map(int, input().split())current_month = 1current_leaves = Nanswer = 0end_month_storm = P + Q - 1while current_leaves > 0:if P <= current_month <= end_month_storm:# Windy seasonremaining_storm = end_month_storm - current_month + 1storm_reduce = remaining_storm * 2 * Mif current_leaves <= storm_reduce:needed = (current_leaves + 2 * M - 1) // (2 * M)answer += neededbreakelse:current_leaves -= storm_reduceanswer += remaining_stormcurrent_month = end_month_storm + 1current_month = current_month % 12if current_month == 0:current_month = 12else:# Regular seasonif current_month < P:months_until_storm = P - current_monthelse:months_until_storm = (12 - current_month) + Pnormal_reduce = months_until_storm * Mif current_leaves <= normal_reduce:needed = (current_leaves + M - 1) // Manswer += neededbreakelse:current_leaves -= normal_reduceanswer += months_until_stormcurrent_month += months_until_stormcurrent_month = current_month % 12if current_month == 0:current_month = 12print(answer)