QOJ.ac

QOJ

حد الوقت: 2.0 s حد الذاكرة: 1024 MB مجموع النقاط: 100

#12006. 机器人

الإحصائيات

有 $N$ 个机器人,编号为 $1$ 到 $N$,以及 $N$ 个天线,编号为 $1$ 到 $N$,它们排列在一条直线上。机器人 $i$ 的坐标为 $a_i$,天线 $i$ 的坐标为 $b_i$。所有坐标互不相同。

目前,所有天线均处于未激活状态。你将逐个激活它们。当你激活一个天线时,距离它最近的机器人(如果有两个机器人距离相等,则选择左侧的那一个)会移动到该天线处,并与天线一同爆炸。

请找到一种激活天线的顺序,使得机器人移动的总距离最小。

输入格式

输入通过标准输入给出,格式如下:

$N$ $a_1 \ a_2 \ \dots \ a_N$ $b_1 \ b_2 \ \dots \ b_N$

数据范围

  • $1 \le N \le 2 \times 10^5$
  • $0 \le a_1 < a_2 < \dots < a_N \le 10^9$
  • $0 \le b_1 < b_2 < \dots < b_N \le 10^9$
  • $a_1, a_2, \dots, a_N, b_1, b_2, \dots, b_N$ 互不相同。
  • 输入中的所有值均为整数。

输出格式

按以下格式输出答案:

$X$ $p_1 \ p_2 \ \dots \ p_N$

其中,$X$ 必须是最小总距离,$p_i$ 是你在第 $i$ 次激活的天线编号。

如果存在多种方案,输出其中任意一种即可。

样例

样例输入 1

3
1 2 3
11 12 13

样例输出 1

30
3 2 1

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.