fb pixel

Algorithms and Data Structures

  • Profound Academy

    • Status
      • 1
        Implementation
      • 2
        Bitwise operations
      • 3
        Prefix Sums
      • 4
        Sliding window / Two pointers
      • 5
        Modular Arithmetic
      • 6
        Number Theory
      • 7
        Binary Search
      • 8
        Basic Sorting
      • 9
        Greedy Algorithms

  • 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 :

    Input

    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 .

    Output

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

    Examples

    Input
    Output
    3 0 0 0 1 1 1
    2
     
    To check your solution you need to sign in
    Sign in to continue