Submit | All submissions | Best solutions | Back to list |
EIDISCENTER - Distribution Center |
ABC company is doing a research to turn one of their n warehouses into a distribution center. These warehouses are connected by n-1 path (connected to other warehouses). Each path has a length. Your task is to find that distribution center so that the total length from the center to other warehouses is minimum.
Input
The first line contains the number of warehouses n (1 ≤ n ≤ 105)
Each of the next n lines contains 3 integers: u, v representing an edge between u and v (0 ≤ u,v ≤ n) and l representing length of uv (l ≤ 105).
Output
Print out a the minimum total length.
Sample
Added by: | Ha Minh Ngoc |
Date: | 2022-12-25 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | CSHARP C++ 4.3.2 CPP CPP14 CPP14-CLANG FSHARP GO JAVA JS-MONKEY NODEJS PHP PYTHON PYPY PYPY3 PYTHON3 RUBY SQLITE SWIFT VB.NET |