結果
問題 | No.1928 Make a Binary Tree |
ユーザー | ikoma |
提出日時 | 2022-05-06 23:38:42 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 736 bytes |
コンパイル時間 | 281 ms |
コンパイル使用メモリ | 87,000 KB |
実行使用メモリ | 143,212 KB |
最終ジャッジ日時 | 2023-09-20 07:01:14 |
合計ジャッジ時間 | 17,499 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 84 ms
71,440 KB |
testcase_01 | AC | 82 ms
71,380 KB |
testcase_02 | AC | 84 ms
71,232 KB |
testcase_03 | AC | 84 ms
71,360 KB |
testcase_04 | AC | 84 ms
71,264 KB |
testcase_05 | AC | 84 ms
71,404 KB |
testcase_06 | AC | 85 ms
71,684 KB |
testcase_07 | AC | 82 ms
71,328 KB |
testcase_08 | AC | 81 ms
71,352 KB |
testcase_09 | AC | 80 ms
71,284 KB |
testcase_10 | AC | 81 ms
71,140 KB |
testcase_11 | AC | 80 ms
71,560 KB |
testcase_12 | AC | 79 ms
71,568 KB |
testcase_13 | AC | 80 ms
71,560 KB |
testcase_14 | AC | 83 ms
71,572 KB |
testcase_15 | AC | 168 ms
80,012 KB |
testcase_16 | AC | 156 ms
79,560 KB |
testcase_17 | AC | 156 ms
78,944 KB |
testcase_18 | AC | 168 ms
80,016 KB |
testcase_19 | AC | 115 ms
77,888 KB |
testcase_20 | AC | 149 ms
79,440 KB |
testcase_21 | AC | 138 ms
78,428 KB |
testcase_22 | AC | 160 ms
80,032 KB |
testcase_23 | AC | 155 ms
79,828 KB |
testcase_24 | AC | 175 ms
81,528 KB |
testcase_25 | AC | 167 ms
80,644 KB |
testcase_26 | AC | 758 ms
121,080 KB |
testcase_27 | AC | 524 ms
104,572 KB |
testcase_28 | AC | 580 ms
108,468 KB |
testcase_29 | AC | 901 ms
127,956 KB |
testcase_30 | AC | 490 ms
103,120 KB |
testcase_31 | AC | 627 ms
111,516 KB |
testcase_32 | AC | 876 ms
127,108 KB |
testcase_33 | AC | 553 ms
106,868 KB |
testcase_34 | AC | 636 ms
111,512 KB |
testcase_35 | AC | 422 ms
143,212 KB |
testcase_36 | TLE | - |
testcase_37 | -- | - |
testcase_38 | -- | - |
testcase_39 | -- | - |
testcase_40 | -- | - |
testcase_41 | -- | - |
testcase_42 | -- | - |
testcase_43 | -- | - |
testcase_44 | -- | - |
testcase_45 | -- | - |
testcase_46 | -- | - |
testcase_47 | -- | - |
testcase_48 | -- | - |
testcase_49 | -- | - |
testcase_50 | -- | - |
testcase_51 | -- | - |
testcase_52 | -- | - |
testcase_53 | -- | - |
testcase_54 | -- | - |
testcase_55 | -- | - |
testcase_56 | -- | - |
testcase_57 | -- | - |
testcase_58 | -- | - |
testcase_59 | -- | - |
ソースコード
import sys input = sys.stdin.readline sys.setrecursionlimit(10 ** 6) if "pypyjit" in sys.builtin_module_names: import pypyjit pypyjit.set_param("max_unroll_recursion=-1") N=int(input()) edge = [[] for _ in range(N)] XY=[list(map(int,input().split())) for _ in range(N-1)] for x,y in XY: x,y=x-1,y-1 edge[x].append(y) edge[y].append(x) visit = [0]*N from heapq import * def dfs(v=0): visit[v]=1 n_tree = [] for to in edge[v]: if visit[to]:continue n,lst = dfs(to) heappush(n_tree,-n) while lst: heappush(n_tree,heappop(lst)) ret = 1 for i in range(min(2,len(n_tree))): ret += -heappop(n_tree) return ret,n_tree ans,_ = dfs() print(ans)