結果
問題 |
No.555 世界史のレポート
|
ユーザー |
![]() |
提出日時 | 2025-01-29 21:49:34 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 521 bytes |
コンパイル時間 | 416 ms |
コンパイル使用メモリ | 82,248 KB |
実行使用メモリ | 82,008 KB |
最終ジャッジ日時 | 2025-01-29 21:49:38 |
合計ジャッジ時間 | 4,130 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 6 WA * 14 |
ソースコード
from heapq import * N = int(input()) C, V = map(int, input().split()) INF = 10 ** 8 D = [INF] * (N + 1) D[1] = C Q = [(C + V, 2, 1)] D[2] = C + V while Q: cost, i, cp = heappop(Q) if cost > D[i]: continue if D[min(N, i + cp)] > D[i] + V: D[min(N, i + cp)] = D[i] + V if N > i + cp: heappush(Q, (D[i + cp], i + cp, cp)) if D[min(N, 2 * i)] > D[i] + C + V: D[min(N, 2 * i)] = D[i] + C + V if N > 2 * i: heappush(Q, (D[2 * i], 2 * i, cp)) print(D[N])