結果

問題 No.1465 Archaea
ユーザー wolgnikwolgnik
提出日時 2020-07-28 13:41:28
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 223 ms / 2,000 ms
コード長 446 bytes
コンパイル時間 140 ms
コンパイル使用メモリ 10,928 KB
実行使用メモリ 19,692 KB
最終ジャッジ日時 2023-08-25 16:06:53
合計ジャッジ時間 2,825 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
8,628 KB
testcase_01 AC 18 ms
8,496 KB
testcase_02 AC 19 ms
8,608 KB
testcase_03 AC 17 ms
8,680 KB
testcase_04 AC 18 ms
8,472 KB
testcase_05 AC 18 ms
8,672 KB
testcase_06 AC 18 ms
8,496 KB
testcase_07 AC 67 ms
11,232 KB
testcase_08 AC 18 ms
8,584 KB
testcase_09 AC 96 ms
13,940 KB
testcase_10 AC 21 ms
8,672 KB
testcase_11 AC 80 ms
11,320 KB
testcase_12 AC 19 ms
8,688 KB
testcase_13 AC 180 ms
19,272 KB
testcase_14 AC 84 ms
11,232 KB
testcase_15 AC 20 ms
8,680 KB
testcase_16 AC 20 ms
8,692 KB
testcase_17 AC 183 ms
19,420 KB
testcase_18 AC 29 ms
9,216 KB
testcase_19 AC 90 ms
14,016 KB
testcase_20 AC 136 ms
14,036 KB
testcase_21 AC 223 ms
19,692 KB
testcase_22 AC 218 ms
19,600 KB
testcase_23 AC 19 ms
8,684 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from collections import deque as dq
from collections import defaultdict as dd
input = sys.stdin.readline
N, K  = map(int, input().split())
Q = dq([1])
d = dd(lambda: 10 ** 10)
d[1] = 0
while len(Q):
  x = Q.popleft()
  if x + 3 <= N and (d[x + 3] > d[x] + 1):
    d[x + 3] = d[x] + 1
    Q.append(x + 3)
  if x * 2 <= N and (d[x * 2] > d[x] + 1):
    d[x * 2] = d[x] + 1
    Q.append(x * 2)
if d[N] <= K: print("YES")
else: print("NO")
0