Chaarshanbegaan at Cafebazaar

Interview

Time limit2sMemory limit512 MB

Summary
Given up to 100 dart coordinates, score each by its distance from the board center and print the total score.
Level

Easy3 of 10

Topics
Math, Implementation, Array
Solved
No attempts yet

Problem

Chaarshanbegaan is a gathering event at Cafebazaar similar to TGIF events at Google. Some entertainment programs like pantomime, foosball, Xbox/PS4, and several board games are part of the event. You are going to set up a dart game in Chaarshanbegaan. As a techie organizing a game for techies, you would rather use a smart screen and write a program to calculate the scores instead of hanging a traditional dartboard and scoring the shots manually. Your program must get the coordinates of dart shots for a player and calculate his/her total score. The score for each dart shot (at point (x,y)(x, y)) is calculated based on its distance from the center of the dartboard (point (0,0)(0, 0)). If the distance is dd millimeters, the score is calculated based on the following table:

Input

The first line of the input contains a single integer NN as the number of dart shots for a player (1≤N≤1001 \le N \le 100). Each of the next NN lines contains two space-separated integers as the coordinates (x,y)(x, y) of a dart shot. The coordinates are in millimeters and their absolute values will not be greater than 300.

Output

Print a single line containing the total score of the player.

Examples2

  1. Example 1

    Input
    2
    4 7
    -31 -5
    
    Expected output
    18
    
  2. Example 2

    Input
    3
    12 -16
    -180 100
    152 10
    
    Expected output
    11