Mouse clicks

You are doing a very manual job of copy-pasting items on a website. As you’re bored, you decide to calculate the minimum distance you need to move the mouse during the task to complete it. You know that you need to make n clicks and the exact coordinate of each click on a screen . You decide to write a program that would print the minimum distance you’ll move your mouse to complete the task in the given order. As a reminder, to calculate the distance between two points and :


The first line of the input contains a single integer n (1 ≀ n ≀ ) the number of mouse clicks. The next n lines contain the floating-point coordinates of the mouse clicks that need to happen . Assume that the mouse is initially at the coordinate .


The program should print the minimum distance you should move your mouse to complete the task.


3 0 0 0 1 1 1


Time limit: 2 seconds

Memory limit: 512 MB

Output limit: 1 MB

To check your solution you need to sign in
Sign in to continue