結果

問題 No.2146 2 Pows
ユーザー とりゐとりゐ
提出日時 2022-12-03 01:04:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,125 ms / 3,000 ms
コード長 529 bytes
コンパイル時間 651 ms
コンパイル使用メモリ 82,428 KB
実行使用メモリ 153,104 KB
最終ジャッジ日時 2024-04-18 10:17:02
合計ジャッジ時間 30,501 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
52,608 KB
testcase_01 AC 38 ms
52,736 KB
testcase_02 AC 36 ms
52,736 KB
testcase_03 AC 37 ms
52,224 KB
testcase_04 AC 37 ms
53,248 KB
testcase_05 AC 1,250 ms
140,800 KB
testcase_06 AC 1,708 ms
153,104 KB
testcase_07 AC 1,371 ms
143,508 KB
testcase_08 AC 1,612 ms
144,836 KB
testcase_09 AC 2,125 ms
144,736 KB
testcase_10 AC 109 ms
77,136 KB
testcase_11 AC 107 ms
77,252 KB
testcase_12 AC 114 ms
77,500 KB
testcase_13 AC 110 ms
77,156 KB
testcase_14 AC 105 ms
77,168 KB
testcase_15 AC 177 ms
81,392 KB
testcase_16 AC 917 ms
114,588 KB
testcase_17 AC 831 ms
111,960 KB
testcase_18 AC 420 ms
94,772 KB
testcase_19 AC 1,414 ms
138,696 KB
testcase_20 AC 1,523 ms
139,904 KB
testcase_21 AC 561 ms
98,348 KB
testcase_22 AC 1,472 ms
137,528 KB
testcase_23 AC 1,098 ms
126,636 KB
testcase_24 AC 1,034 ms
121,172 KB
testcase_25 AC 1,222 ms
131,728 KB
testcase_26 AC 1,599 ms
150,012 KB
testcase_27 AC 1,174 ms
134,336 KB
testcase_28 AC 1,151 ms
119,444 KB
testcase_29 AC 363 ms
92,476 KB
testcase_30 AC 891 ms
119,096 KB
testcase_31 AC 1,049 ms
131,676 KB
testcase_32 AC 334 ms
86,508 KB
testcase_33 AC 961 ms
123,680 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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))
0