QOJ.ac

QOJ

Límite de tiempo: 1 s Límite de memoria: 128 MB Puntuación total: 100

#6082. Bajtokrąg

Estadísticas

Bajtokrąg 由 $n$ 个城市组成,编号从 $0$ 到 $n-1$,排列方式较为特殊。其中 $n-1$ 个城市位于一个圆周上,依次为编号 $1, 2, \ldots, n-1$ 的城市。圆周上相邻的城市之间由双向道路连接。Bajtokrąg 的首都(编号为 $0$ 的城市)位于圆心,并与所有其他城市通过道路相连。

我们已知 Bajtokrąg 中每条道路的通行时间。Bajtokrąg 当局希望改善居民在城市间的交通。为此,他们想要选出两个距离最远(以通行时间衡量)的城市,并在那里修建机场。

输入格式

输入的第一行包含一个整数 $n$ ($3 \le n \le 500\,000$),表示 Bajtokrąg 的城市数量。第二行包含 $n-1$ 个正整数,表示圆周上相邻城市之间的通行时间(即第 $i$ 个数表示编号为 $i$ 的城市与圆周上下一个城市之间的通行时间)。第三行包含 $n-1$ 个正整数,表示首都与圆周上各城市之间的通行时间(即第 $i$ 个数表示首都与编号为 $i$ 的城市之间的通行时间)。假设圆周上所有相邻城市之间的通行时间之和不超过 $10^{9}$。

输出格式

输出仅一行,包含一个整数,表示 Bajtokrąg 中距离最远的一对城市之间的通行时间。

样例

输入 1

6
1 4 5 1 6
3 5 1 8 2

输出 1

7

说明

距离最远的一对城市是 $(2, 4)$,它们之间的通行时间为 $7$。应该在这两个城市修建机场。

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.