結果

問題 No.994 ばらばらコイン
ユーザー knk_keiknk_kei
提出日時 2021-02-03 03:16:37
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 408 ms / 2,000 ms
コード長 374 bytes
コンパイル時間 88 ms
コンパイル使用メモリ 10,664 KB
実行使用メモリ 26,764 KB
最終ジャッジ日時 2023-09-12 11:44:15
合計ジャッジ時間 6,410 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
8,476 KB
testcase_01 AC 20 ms
8,424 KB
testcase_02 AC 371 ms
26,576 KB
testcase_03 AC 396 ms
26,764 KB
testcase_04 AC 407 ms
26,676 KB
testcase_05 AC 204 ms
17,564 KB
testcase_06 AC 408 ms
26,668 KB
testcase_07 AC 396 ms
26,724 KB
testcase_08 AC 273 ms
20,908 KB
testcase_09 AC 375 ms
25,628 KB
testcase_10 AC 277 ms
21,136 KB
testcase_11 AC 308 ms
22,636 KB
testcase_12 AC 340 ms
23,948 KB
testcase_13 AC 18 ms
8,496 KB
testcase_14 AC 18 ms
8,468 KB
testcase_15 AC 18 ms
8,488 KB
testcase_16 AC 18 ms
8,576 KB
testcase_17 AC 18 ms
8,472 KB
testcase_18 AC 18 ms
8,592 KB
testcase_19 AC 18 ms
8,508 KB
testcase_20 AC 18 ms
8,468 KB
testcase_21 AC 18 ms
8,516 KB
testcase_22 AC 18 ms
8,472 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque

n, k = map(int, input().split())
x, y = [0] * (n - 1), [0] * (n - 1)
e = [[] for _ in range(n)]
for i in range(n - 1):
    x[i], y[i] = map(int, input().split())
    x[i] -= 1
    y[i] -= 1
    e[x[i]].append(y[i])
    e[y[i]].append(x[i])
# n<=k と 単純に深さの和を足せば良いbfs
if k > n:
    print(-1)
else:
    print(k - 1)
0