Logo
(追記) (追記ここまで)

23103번 - Academic Distance 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB46340537886.897%

문제

Starting from the second semester, Mr. Eto will take classes at Kyoto University. Mr. Eto is not accustomed to the structure of the university because in the first semester he had only online lectures.

There are $N$ classes today. The schedule contains the coordinates of $N$ classrooms in the order in which they have to be visited. The coordinates of the $i$-th classroom are $(x_i, y_i)$. Assuming Mr. Eto starts the day in the first classroom, and ends in the $N$-th classroom, calculate the total distance he has to travel.

In Kyoto University campus, the distance traveled from the coordinates $(a, b)$ to the coordinates $(c, d)$ is equal to $|a-c| + |b-d|$.

입력

The first line of the input contains one integer $N$ (1ドル \le N \le 100$), the number of classrooms in today's schedule. Then $N$ lines follow, $i$-th of them containing integer coordinates $x_i$ and $y_i$ of the $i$-th classroom in the schedule ($-100 \le x_i, y_i \le 100$).

출력

Print one integer: the total distance traveled by Mr. Eto by the end of the day.

제한

예제 입력 1

3
1 2
2 3
4 6

예제 출력 1

7

예제 입력 2

1
0 0

예제 출력 2

0

예제 입력 3

4
-2 3
1 4
5 2
4 -2

예제 출력 3

15

힌트

출처

Camp > Petrozavodsk Programming Camp > Summer 2021 > Day 1: Kyoto U Contest 1 A번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /