結果
問題 |
No.2099 [Cherry Alpha B] Time Machine
|
ユーザー |
|
提出日時 | 2025-05-01 14:34:19 |
言語 | PyPy3 (7.3.15) |
結果 |
MLE
|
実行時間 | - |
コード長 | 778 bytes |
コンパイル時間 | 422 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 786,292 KB |
最終ジャッジ日時 | 2025-05-01 14:34:24 |
合計ジャッジ時間 | 4,997 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 8 MLE * 1 -- * 63 |
ソースコード
## https://yukicoder.me/problems/no/2099 def main(): T = int(input()) X, A = map(int, input().split()) Y, B = map(int, input().split()) # yが取りうる最小値を取得 if T >= 0: y_min = 0 else: y_min = (- T) // B + (1 if (-T) % B > 0 else 0) # 本処理 t_map = {} t = (T + y_min * B) % A cost = y_min while t not in t_map: t_map[t] = cost cost += 1 t += B t %= A min_answer = float("inf") for t, cost in t_map.items(): xx = T + cost * B answer = cost * Y + t xx0 = xx - t a = xx0 // A answer += a * X min_answer = min(min_answer, answer) print(min_answer) if __name__ == "__main__": main()