Funny Salesman
시간 제한1초메모리 제한512 MB
가중치가 30 이하인 간선을 가진 트리에서 모든 정점을 한 번씩 나열해 연속한 두 정점 사이 경로의 최대 간선 가중치에 대한 2의 거듭제곱 합을 최대로 만든다.
문제
You are given a tree, and each edge has a non-negative integer weight.
Let --- The maximum of the edge weights on the unique simple path between vertices and .
Find the largest among all permutations of vertices .
입력
The first line contains one integer (): the number of vertices in the tree.
Each of the next lines contains three integers (), an edge in the tree with endpoints having weight .
출력
Print one integer: the largest .
힌트
In the first example, one of the optimal permutations is .