#Q4. 「一本通 1.1 例 4」加工生产调度

「一本通 1.1 例 4」加工生产调度

Description

A factory has received an order for nn products. These nn products need to be processed in workshops A and B, and they must be processed in workshop A before they can be processed in workshop B.

The processing times for product ii in workshops A and B are AiA_i and BiB_i, respectively. Determine the optimal processing sequence for these nn products to minimize the total processing time.

Here, the total processing time refers to the time from the start of processing the first product until all products have completed processing in both workshops A and B.

Input Format

The first line contains a single integer nn, representing the number of products.

The next nn numbers represent the processing times for each product in workshop A.

The last nn numbers represent the processing times for each product in workshop B.

Output Format

The first line should contain a single integer, the minimum total processing time.

The second line should list one possible processing sequence that achieves this minimum time.

Sample 1

5
3 5 8 7 10
6 2 1 4 9

34
1 5 4 2 3

Data Range and Hint

For 100%100\% of the data, 0<n<10000<n<1000, 1Ai,Bi3501\le A_i,B_i\le 350.

Note: The SPJ for this problem is sensitive to trailing spaces. Please ensure there are no trailing spaces at the end of your output lines.