G.W. Coding Contest 2 P2: PC Part Picking
Kevin is building an awesome new PC and he needs to purchase components. The components are located at N different shops on a grid, and each shop has a distinct coordinate pair such that no shops share the same \(x\)-coordinate.
Kevin starts at \((0, 0)\), visits each shop, and ends at \((100, 100)\). He needs to visit the shops in an increasing order of \(x\)-coordinates. Given \(N\) distinct coordinate pairs for each shop \((a, b)\), \(\{0 < a, b < 100\}\), determine the shortest possible distance that Kevin needs to travel to reach every shop rounded down to the nearest integer.
Note: The answer should be rounded down, intermediate calculations should always remain as decimals to maintain accuracy.
The first line of input will contain \(N\), the number of shops Kevin needs to visit.
The next \(N\) lines will contain two integers, \(a\) and \(b\), seperated by a space, representing the \(x\) and \(y\) coordinates of each shop respectively.
The output will consist of a single integer, the total distance Kevin must travel if he takes the shortest path.
Sample Input 1:
Sample Output 1:
Submit Solution