結果

問題 No.2146 2 Pows
ユーザー とりゐとりゐ
提出日時 2022-12-02 23:13:09
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 663 bytes
コンパイル時間 287 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 249,596 KB
最終ジャッジ日時 2024-04-18 08:29:31
合計ジャッジ時間 5,657 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
58,496 KB
testcase_01 AC 50 ms
62,080 KB
testcase_02 AC 40 ms
52,608 KB
testcase_03 WA -
testcase_04 AC 45 ms
60,416 KB
testcase_05 TLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

n,a,b,c=map(int,input().split())
inf=1<<62
dp=[inf]*n
res=0
for i in range(n):
  dp[i%n]=a*i+(i>0)*b

from heapq import heappop,heappush
ans=dp.copy()
ans0=inf
for j in range(1,60):
  res+=c
  hq=[]
  ndp=[inf]*n
  d=pow(2,j,n)
  for i in range(n):
    ndp[(i+d)%n]=dp[i]+a+b
    heappush(hq,(dp[i]+a+b,(i+d)%n))
  
  
  while hq:
    val,idx=heappop(hq)
    if idx==0:
      ans0=min(ans0,val+res)
    if ndp[idx]+a<ndp[(idx+d)%n]:
      ndp[(idx+d)%n]=ndp[idx]+a
      heappush(hq,(ndp[(idx+d)%n],(idx+d)%n))
  
  dp=[min(dp[i],ndp[i]) for i in range(n)]
  ans=[min(ans[i],dp[i]+res) for i in range(n)]
  #print(dp)
  
ans[0]=ans0
print('\n'.join(map(str,ans)))
0