Robin and Gold coins
All submissions for this problem are available.
A thief named 'Robin' stole X amount of gold coins from a millionare and was escaping from the cops. During his escape he ran through N cities (numbered from 1 to N) . He knew that his gold would be gone if he was caught by the cops. So he dicided to hide his gold coins at each of the N cities. If he were to hide coins, at each of the N cities, find the minimum length he had to travel so that he hides all the coins among all the cities and is caught empty handed by the police. Assume initially he is at city 1.
- First line contains a single natural number N denoting the number of cities.
- Next N-1 lines contain 3 integers ai, bi and li were ai and bi are the cities. Between ai and bi there is a bidirectional road of length of li.
- A single number denoting the minimum length he has to travel.
- 1 <= N <= 20
- 1 <= ai, bi <= N
- 1 <= li <= 1000
Input: 3 1 3 4 1 2 2 Output: 8
Input: 4 4 3 1 4 2 2 1 2 1 Output: 4
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, CLOJ, FS|
Fetching successful submissions