結果
| 問題 |
No.555 世界史のレポート
|
| コンテスト | |
| ユーザー |
ntuda
|
| 提出日時 | 2025-01-29 21:53:28 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 520 bytes |
| コンパイル時間 | 165 ms |
| コンパイル使用メモリ | 82,788 KB |
| 実行使用メモリ | 72,964 KB |
| 最終ジャッジ日時 | 2025-01-29 21:53:30 |
| 合計ジャッジ時間 | 2,196 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 WA * 1 |
ソースコード
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, i))
print(D[N])
ntuda