結果
問題 |
No.555 世界史のレポート
|
ユーザー |
|
提出日時 | 2022-09-15 00:15:32 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 39 ms / 2,000 ms |
コード長 | 581 bytes |
コンパイル時間 | 363 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 11,136 KB |
最終ジャッジ日時 | 2024-12-15 13:11:24 |
合計ジャッジ時間 | 1,886 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 20 |
ソースコード
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 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))