/*
1.树的重心本质就是深度优先遍历的来的
*/
`` import java.util.*;
public class Main{
static int N = 100010;
static int[] h = new int[N];//存储头节点
static int[] e = new int[N2];//存储值
static int[] ne = new int[N2];//存储下一个节点
static int idx;//索引值
static int ans = N;
static int n;
static boolean[] stat = new boolean[N];//判断这个值是否被遍历过
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
n = sc.nextInt();
Arrays.fill(h,1,n + 1,-1);
for(int i = 0;i < n - 1;i){
int a = sc.nextInt();
int b = sc.nextInt();
add(a,b);
add(b,a);
}
dfs(1);
System.out.print(ans);
}
static void add(int a,int b){
e[idx] = b; ne[idx] = h[a];h[a] = idx;
}
static int dfs(int u){
stat[u] = true;
int sum = 1;//表示该节点的子节点有多少个包括自己
int res = 0;//该节点的最多节点数
for(int i = h[u];i != -1;i= ne[i]){
int j = e[i];
if(!stat[j]){
int x = dfs(j);
res = Math.max(res,x);
sum += x;
}
}
res = Math.max(n - sum,res);
ans = Math.min(res,ans);
return sum;
}
}``