結果
| 問題 |
No.555 世界史のレポート
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-09-15 00:10:43 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 629 bytes |
| コンパイル時間 | 293 ms |
| コンパイル使用メモリ | 82,176 KB |
| 実行使用メモリ | 71,552 KB |
| 最終ジャッジ日時 | 2024-12-15 13:05:00 |
| 合計ジャッジ時間 | 2,078 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 WA * 1 |
ソースコード
from heapq import heapify, heappop, heappush
n = int(input())
c, v = map(int, input().split())
H = [(c, 1, 1)]
INF = 10**18
DP = [INF for _ in range(n + 1)]
DP[1] = c
heapify(H)
while H:
cost, num, c_num = heappop(H)
if cost > DP[min(num, n)]:
continue
if num >= n:
print(cost)
break
if c_num != num:
if cost + c + v < DP[min(num * 2, n)]:
DP[min(num * 2, n)] = cost + c + v
heappush(H, (cost + c + v, num * 2, num))
if cost + v < DP[min(num + c_num, n)]:
DP[min(num + c_num, n)] = cost + v
heappush(H, (cost + v, num + c_num, c_num))