結果
問題 | No.806 木を道に |
ユーザー | tomarint2 |
提出日時 | 2019-03-22 21:53:20 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 517 bytes |
コンパイル時間 | 167 ms |
コンパイル使用メモリ | 81,580 KB |
実行使用メモリ | 81,756 KB |
最終ジャッジ日時 | 2023-10-19 09:03:53 |
合計ジャッジ時間 | 3,955 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 41 ms
53,508 KB |
testcase_01 | AC | 41 ms
53,296 KB |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | AC | 43 ms
55,344 KB |
testcase_09 | AC | 43 ms
55,344 KB |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | AC | 106 ms
79,748 KB |
testcase_25 | AC | 123 ms
81,628 KB |
testcase_26 | AC | 91 ms
77,788 KB |
testcase_27 | AC | 132 ms
81,628 KB |
testcase_28 | AC | 70 ms
70,848 KB |
ソースコード
import collections def solve(): ans=0 n=int(input()) side=[] degree=[0 for i in range(n)] for i in range(n-1): a,b=map(int,input().split()) side.append((a,b)) degree[a-1]+=1 degree[b-1]+=1 c = collections.Counter(degree) if c[1]==2: return 0 ck = sorted(c.keys(),reverse=True) for k in ck: if k > 2: ans+=k-2 #if c[1]>=k-2: # c[1]-=k-2 # c[2]+=k-2 return ans print(solve())