← 返回 coinbase 的题目列表Find Shortest Path for All Items
类型:online_judge
Given a restaurant menu that includes multiple food items, each food item corresponds to a location coordinate. Write an algorithm to find out the shortest path that visits all food items. The path is based on the shortest total distance of the given coordinates. Do not assume that all points are on a single line. Output the shortest path total length starting from the initial point (coordinate 0,0). Input format: [number of food items, [coord1], [coord2], ...]. Example Input: [3, [1,2], [3,4], [5,6]]. Output is an integer representing the shortest total path length that visits all food items in order.
Example
Input
3
1
2
3
4
5
6