Logo
(追記) (追記ここまで)

18777번 - Delegation (Platinum) 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB309857728.519%

문제

Farmer John's farm consists of $N$ pastures (2ドル \leq N \leq 10^5$) connected by $N-1$ roads, so that any pasture is reachable from any other pasture. That is, the farm is a tree. But after 28 years of dealing with the tricky algorithmic problems that inevitably arise from trees, FJ has decided that a farm in the shape of a tree is just too complex. He believes that algorithmic problems are simpler on paths.

Thus, his plan is to partition the set of roads into several paths and delegate responsibility for these path among his worthy farm hands. He doesn't care about the number of paths. However, he wants to make sure that these paths are all as large as possible, so that no farm hand can get away with asymptotically inefficient algorithms!

Help Farmer John determine the largest positive integer $K$ such that the roads can be partitioned into paths of length at least $K$.

입력

The first line contains a single integer $N$.

The next $N-1$ lines each contain two space-separated integers $a$ and $b$ describing an edge between vertices $a$ and $b$. Both $a$ and $b$ are in the range 1ドル \ldots N$.

출력

Print $K$.

제한

예제 입력 1

8
1 2
1 3
1 4
4 5
1 6
6 7
7 8

예제 출력 1

3

힌트

One possible set of paths is as follows: $2ドル-1-6-7-8, 3-1-4-5$$

출처

Olympiad > USA Computing Olympiad > 2019-2020 Season > USACO 2020 February Contest > Platinum 1번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /