406866: GYM102586 F Robots
Description
There are $$$N$$$ robots numbered from $$$1$$$ through $$$N$$$ and $$$N$$$ antennas numbered from $$$1$$$ through $$$N$$$ in a straight line. The coordinate of the robot $$$i$$$ is $$$a_i$$$ and the coordinate of the antenna $$$i$$$ is $$$b_i$$$. All coordinates are distinct.
Currently, all antennas are inactive. You are going to activate them one by one. When you activate an antenna, the nearest robot (if two robots are closest to it, only the left one) moves to the antenna and explodes along with it.
Find an order to activate antennas so that the total distance of robots' moves is minimum possible.
InputInput is given from Standard Input in the following format:
$$$N$$$
$$$a_1$$$ $$$a_2$$$ $$$\dots$$$ $$$a_N$$$
$$$b_1$$$ $$$b_2$$$ $$$\dots$$$ $$$b_N$$$
Constraints:
- $$$1 \leq N \leq 2 \times 10^5$$$
- $$$0 \leq a_1 < a_2 < \dots < a_N \leq 10^9$$$
- $$$0 \leq b_1 < b_2 < \dots < b_N \leq 10^9$$$
- $$$a_1, a_2, \dots, a_N, b_1, b_2, \dots, b_N$$$ are all distinct.
- All values in input are integers.
Print the answer in the following format:
$$$X$$$
$$$p_1$$$ $$$p_2$$$ $$$\dots$$$ $$$p_N$$$
Here, $$$X$$$ must be a minimum total distance, and $$$p_i$$$ is the index of the antenna that you activate in the $$$i$$$-th.
If there are multiple solutions, you can print any of them.
ExampleInput3 1 2 3 11 12 13Output
30 3 2 1