QOJ.ac

QOJ

时间限制: 2 s 内存限制: 512 MB 总分: 100 难度: [显示]

#1804. アカデミック・ディスタンス

统计

2学期から、江藤さんは京都大学で授業を受けることになりました。1学期はオンライン講義のみだったため、江藤さんは大学の構造に慣れていません。

今日受ける授業は $N$ コマあります。スケジュールには、訪れるべき $N$ 個の教室の座標が、訪れる順番に記載されています。$i$ 番目の教室の座標は $(x_i, y_i)$ です。江藤さんが1番目の教室から1日を始め、 $N$ 番目の教室で1日を終えると仮定して、移動する総距離を計算してください。

京都大学のキャンパスにおいて、座標 $(a, b)$ から座標 $(c, d)$ までの移動距離は $|a - c| + |b - d|$ です。

入力

入力の1行目には、今日のスケジュールにある教室の数 $N$ ($1 \le N \le 100$) が与えられます。続く $N$ 行には、スケジュールにおける $i$ 番目の教室の整数座標 $x_i$ と $y_i$ が与えられます ($-100 \le x_i, y_i \le 100$)。

出力

江藤さんが1日の終わりまでに移動する総距離を整数で出力してください。

入出力例

入力 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.