結果
| 問題 |
No.2146 2 Pows
|
| コンテスト | |
| ユーザー |
とりゐ
|
| 提出日時 | 2022-12-03 01:04:35 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 2,152 ms / 3,000 ms |
| コード長 | 529 bytes |
| コンパイル時間 | 177 ms |
| コンパイル使用メモリ | 82,376 KB |
| 実行使用メモリ | 152,852 KB |
| 最終ジャッジ日時 | 2024-10-10 03:29:05 |
| 合計ジャッジ時間 | 30,750 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 32 |
ソースコード
from heapq import*
n,a,b,c=map(int,input().split())
inf=1<<61
dist=[[inf]*2 for i in range(n)]
seen=[[0]*2 for i in range(n)]
hq=[(0,0,0)]
while hq:
d,i,f=heappop(hq)
if dist[i][f]<d:
continue
if i!=0 or f!=0:
seen[i][f]=1
if seen[(i+1)%n][1]==False and d+a+(1-f)*b<dist[(i+1)%n][1]:
dist[(i+1)%n][1]=d+a+(1-f)*b
heappush(hq,(d+a+(1-f)*b,(i+1)%n,1))
if seen[(2*i)%n][0]==False and d+c<dist[(2*i)%n][0] and i!=0:
dist[(2*i)%n][0]=d+c
heappush(hq,(d+c,(2*i)%n,0))
for i in dist:
print(min(i))
とりゐ