EIHTP - The highest total point
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:
Dạng bài
Ngôn ngữ cho phép
C, C++, Java, Kotlin, Pascal, PyPy, Python, Scratch
Given a rooted tree with each node has a 'point' value. Find a path that has total points of all nodes in the path is highest.
Input
- The first line contains two integer ~n~ and ~m~ which are the number of nodes in the tree and the root of the given tree. Nodes are numbered from ~0~ to ~n - 1~ ~(0 ≤ m < n ≤ 10^5)~
- The second line contains ~n~ integers which are points of all nodes, respectively.
- Each line in the next ~(n – 1)~ lines contains two integers ~a, b~ which represent an edge in the tree.
Output
- An integer representing the highest total point.
Sample Input
5 0
3 2 4 1 5
0 1
0 2
1 3
1 4
Sample Output
10
Bình luận