結果

問題 No.806 木を道に
ユーザー FromBooskaFromBooska
提出日時 2023-09-12 19:52:17
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 166 ms / 2,000 ms
コード長 262 bytes
コンパイル時間 524 ms
コンパイル使用メモリ 86,588 KB
実行使用メモリ 78,480 KB
最終ジャッジ日時 2023-09-12 19:52:23
合計ジャッジ時間 6,581 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,076 KB
testcase_01 AC 70 ms
71,004 KB
testcase_02 AC 72 ms
71,320 KB
testcase_03 AC 67 ms
71,296 KB
testcase_04 AC 70 ms
71,264 KB
testcase_05 AC 70 ms
71,140 KB
testcase_06 AC 70 ms
70,880 KB
testcase_07 AC 69 ms
71,196 KB
testcase_08 AC 70 ms
71,052 KB
testcase_09 AC 70 ms
71,020 KB
testcase_10 AC 118 ms
77,056 KB
testcase_11 AC 99 ms
76,904 KB
testcase_12 AC 129 ms
77,556 KB
testcase_13 AC 117 ms
77,540 KB
testcase_14 AC 142 ms
77,648 KB
testcase_15 AC 133 ms
77,980 KB
testcase_16 AC 107 ms
77,352 KB
testcase_17 AC 127 ms
77,900 KB
testcase_18 AC 97 ms
77,204 KB
testcase_19 AC 101 ms
77,280 KB
testcase_20 AC 124 ms
77,500 KB
testcase_21 AC 112 ms
77,632 KB
testcase_22 AC 137 ms
77,800 KB
testcase_23 AC 166 ms
77,756 KB
testcase_24 AC 112 ms
77,500 KB
testcase_25 AC 124 ms
77,708 KB
testcase_26 AC 106 ms
77,192 KB
testcase_27 AC 133 ms
78,480 KB
testcase_28 AC 91 ms
76,640 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# 次数2を超える数の和でいいのか

N = int(input())
deg = [0]*(N+1)

for i in range(N-1):
    a, b = map(int, input().split())
    deg[a] += 1
    deg[b] += 1
    
ans = 0
for i in range(1, N+1):
    calc = max(0, deg[i]-2)
    ans += calc
print(ans)
0