QOJ.ac

QOJ

Limite de temps : 2 s Limite de mémoire : 512 MB Points totaux : 100 Difficulté: [afficher]

#1804. 學術距離

Statistiques

從第二學期開始,Eto 先生將在京都大學上課。由於第一學期只有線上課程,Eto 先生並不習慣這所大學的結構。

今天共有 $N$ 堂課。課表包含了 $N$ 間教室的座標,必須依照順序前往。第 $i$ 間教室的座標為 $(x_i, y_i)$。假設 Eto 先生從第一間教室開始,並在第 $N$ 間教室結束,請計算他總共需要移動的距離。

在京都大學校園內,從座標 $(a, b)$ 移動到座標 $(c, d)$ 的距離等於 $|a - c| + |b - d|$。

輸入格式

輸入的第一行包含一個整數 $N$ ($1 \le N \le 100$),代表今天課表中的教室數量。接著有 $N$ 行,其中第 $i$ 行包含第 $i$ 間教室的整數座標 $x_i$ 和 $y_i$ ($-100 \le x_i, y_i \le 100$)。

輸出格式

輸出一個整數:Eto 先生在一天結束時總共移動的距離。

範例

輸入格式 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

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.