#P1248. 加工生产调度
加工生产调度
Description
A factory has received orders for products. Each product must be processed in workshop A first and then in workshop B. At any moment, each workshop can process at most one product.
For product , its processing times in workshops A and B are and , respectively. Determine an order to process the products that minimizes the total processing time.
The total processing time is defined as the time from starting the first product until all products have finished processing in both workshops A and B.
Input Format
- The first line contains a single integer , the number of products.
- The second line contains integers, the processing times of the products in workshop A.
- The third line contains integers, the processing times of the products in workshop B.
Output Format
- The first line contains one integer, the minimal total processing time.
- The second line contains one processing order that achieves the minimal total processing time. Output the product indices (from to ) separated by spaces.
5
3 5 8 7 10
6 2 1 4 9
34
1 5 4 2 3
Hint
Constraints: , .
Translated by ChatGPT 5
京公网安备 11011102002149号