Academic Distance
InterviewTime limit2sMemory limit512 MB
Given N points in order, compute the total Manhattan distance along the path from the first point to the last.
- Level
Easy1 of 10
- Topics
- Implementation, Math, Array
- Solved
- No attempts yet
Problem
Starting from the second semester, Mr. Eto will take classes at Kyoto University. He is not accustomed to the structure of the university because in the first semester he had only online lectures.
There are classes today. The schedule contains the coordinates of classrooms in the order in which they have to be visited. The coordinates of the -th classroom are . Assuming Mr. Eto starts the day in the first classroom and ends in the -th classroom, calculate the total distance he has to travel.
On the Kyoto University campus, the distance traveled from the coordinates to the coordinates is .
Input
The first line of the input contains one integer (), the number of classrooms in today's schedule. Then lines follow, the -th of them containing the integer coordinates and of the -th classroom in the schedule ().
Output
Print one integer: the total distance traveled by Mr. Eto by the end of the day.