結果
| 問題 | 
                            No.2146 2 Pows
                             | 
                    
| コンテスト | |
| ユーザー | 
                             とりゐ
                         | 
                    
| 提出日時 | 2022-12-02 23:11:37 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 663 bytes | 
| コンパイル時間 | 528 ms | 
| コンパイル使用メモリ | 82,176 KB | 
| 実行使用メモリ | 249,336 KB | 
| 最終ジャッジ日時 | 2024-10-10 01:40:24 | 
| 合計ジャッジ時間 | 5,816 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 2 WA * 1 TLE * 1 -- * 28 | 
ソースコード
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,20):
  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)))
            
            
            
        
            
とりゐ