結果
| 問題 | No.1465 Archaea | 
| コンテスト | |
| ユーザー |  rodea | 
| 提出日時 | 2021-04-09 16:36:42 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 156 ms / 2,000 ms | 
| コード長 | 445 bytes | 
| コンパイル時間 | 193 ms | 
| コンパイル使用メモリ | 82,460 KB | 
| 実行使用メモリ | 79,256 KB | 
| 最終ジャッジ日時 | 2024-06-24 23:29:28 | 
| 合計ジャッジ時間 | 3,169 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 20 | 
ソースコード
import heapq
n, k = map(int, input().split())
dp = [10 ** 9] * (n + 1)
dp[1] = 0
que = [1]
heapq.heapify(que)
while len(que):
    cur = heapq.heappop(que)
    if cur * 2 <= n and dp[cur] + 1 < dp[cur * 2]:
        dp[cur * 2] = dp[cur] + 1
        heapq.heappush(que, cur * 2)
    if cur + 3 <= n and dp[cur] + 1 < dp[cur + 3]:
        dp[cur + 3] = dp[cur] + 1
        heapq.heappush(que, cur + 3)
print("YES") if dp[n] <= k else print("NO")
            
            
            
        