結果

問題 No.1465 Archaea
ユーザー yuusanlondonyuusanlondon
提出日時 2021-04-02 21:54:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 291 ms / 2,000 ms
コード長 620 bytes
コンパイル時間 311 ms
コンパイル使用メモリ 87,024 KB
実行使用メモリ 111,940 KB
最終ジャッジ日時 2023-08-25 16:13:32
合計ジャッジ時間 4,941 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
71,380 KB
testcase_01 AC 62 ms
71,376 KB
testcase_02 AC 71 ms
75,660 KB
testcase_03 AC 63 ms
71,404 KB
testcase_04 AC 62 ms
71,372 KB
testcase_05 AC 61 ms
71,300 KB
testcase_06 AC 61 ms
71,048 KB
testcase_07 AC 144 ms
86,456 KB
testcase_08 AC 64 ms
71,200 KB
testcase_09 AC 169 ms
90,880 KB
testcase_10 AC 62 ms
71,048 KB
testcase_11 AC 161 ms
89,532 KB
testcase_12 AC 94 ms
77,816 KB
testcase_13 AC 247 ms
103,764 KB
testcase_14 AC 173 ms
90,016 KB
testcase_15 AC 98 ms
76,288 KB
testcase_16 AC 93 ms
77,708 KB
testcase_17 AC 261 ms
105,108 KB
testcase_18 AC 120 ms
79,196 KB
testcase_19 AC 181 ms
89,996 KB
testcase_20 AC 227 ms
97,188 KB
testcase_21 AC 291 ms
111,940 KB
testcase_22 AC 286 ms
111,784 KB
testcase_23 AC 64 ms
71,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq
INF=10**9
def Dijkstra(graph, start):
  dist=[INF]*len(graph)
  queue=[(0, start)]
  dist[start]=0
  while queue:
    path_len, v=heapq.heappop(queue)
    if path_len==dist[v]: 
      for w in graph[v]:
        if dist[w[0]]>path_len+w[1]:
          heapq.heappush(queue, (path_len+w[1], w[0]))
          dist[w[0]]=path_len+w[1]     
  return dist
graph=[]
n,k=map(int,input().split())
for i in range(n+1):
  graph.append([])

for i in range(1,n+1):
  if i+3<=n:
    graph[i].append((i+3,1))
  if i*2<=n:
    graph[i].append((2*i,1))
dist=Dijkstra(graph,1)
if dist[n]<=k:
  print('YES')
else:
  print('NO')
0