結果
問題 |
No.2146 2 Pows
|
ユーザー |
![]() |
提出日時 | 2022-12-03 00:24:23 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 668 bytes |
コンパイル時間 | 905 ms |
コンパイル使用メモリ | 82,720 KB |
実行使用メモリ | 344,124 KB |
最終ジャッジ日時 | 2024-10-10 02:47:06 |
合計ジャッジ時間 | 5,581 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 3 TLE * 1 -- * 28 |
ソースコード
from heapq import heappush, heappop import sys input = sys.stdin.readline N, A, B, C = map(int, input().split()) L = 31 ans = [10**18] * N dist = [10**18] * (N*L) heap = [] for z in range(L): heappush(heap, (A+B+z*C, N*z+(2**z)%N)) while heap: d, v = heappop(heap) if d > dist[v]: continue z, i = divmod(v, N) ans[i] = min(ans[i], d) # same nd, u = d+A, N*z+(i+2**z)%N if dist[u] > nd: dist[u] = nd heappush(heap, (nd, u)) # change for w in range(z+1, L): nd, u = d+B+(w-z)*C, N*w+i if dist[u] > nd: dist[u] = nd heappush(heap, (nd, u)) print(*ans, sep="\n")