QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 512 MB Total points: 100 Difficulty: [show]

#1804. 学术距离

Statistics

从第二学期开始,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.