EILOCAL2 - Local Area Network (Easy)

Xem dạng PDF

Gửi bài giải

Điểm: 1,00 (OI)
Giới hạn thời gian: 1.0s
Giới hạn bộ nhớ: 256M
Input: stdin
Output: stdout

Nguồn bài:
Hà Minh Ngọc
Dạng bài
Ngôn ngữ cho phép
C, C++, Java, Kotlin, Pascal, PyPy, Python, Scratch

Local Area Network (LAN) needs multiple Switches. The tranmission time is proportional to the length of the wire (skip the role of Switch). Find the longest distance from the Internet Network Provider (ID ~0~) to a customer.

Input

  • The first line is an integer ~n~ ~(1 \le n \le 10^5)~ - the number of switches
  • ~n-1~ next lines each contains three integers ~u, v~ and ~w~ which denote switch ~u~ is connected to switch ~v~ by cable with length ~w~ ~(1 \le w \le 10^5, 0 \le u, v < n)~

Output

  • Print out the longest tranmission distance from the network provider

Example Input 1

4
0 1 2
0 2 2
0 3 3

Example Output 1

3

Example Input 2

5
0 1 2
0 2 2
0 3 3
2 4 2

Example Output 2

4

Bình luận

Hãy đọc nội quy trước khi bình luận.


Không có bình luận tại thời điểm này.