There are N cities in the wonderland. The cities are numbered from 1 to N. The wonderland can be represented as a three-dimensional plane. The city i is at point (Xi, Yi, Zi).
The cost of going from the city with coordinates (Xi, Yi, Zi) to city with coordinates (Xj, Yj, Zj) is |Xi - Xj| + |Yi - Yj| + max(0, Zj - Zi).
Alice wants to find the minimum cost it takes to travel all the cities starting from City 1 and then coming back to City 1 again.
INPUT:
The first line of input contains a single integer N, no of cities. (2 ≤ N ≤ 17)
Following N lines contain the coordinates of each city i.e. (Xi, Yi, Zi). (-106 ≤ Xi, Yi, Zi ≤ 106)
OUTPUT:
Print a single integer denoting the minimum cost of travelling all the cities and coming back to City 1 again
Answers
Answered by
0
Answer:
here this your answer
Explanation:
make a brilliant
Attachments:
Similar questions