#P2514. [HAOI2010] 工厂选址
[HAOI2010] 工厂选址
Description
There are coal mines in a region, where the -th mine produces tons per year. There is an existing thermal power plant that requires exactly tons of coal per year. Its fixed annual operating cost (excluding coal transportation) is yuan. The transportation cost per ton of raw coal from the -th mine to the existing plant is yuan.
A new power plant is planned to be built. All raw coal mined from the mines will be entirely supplied to these two power plants. There are candidate sites for the new plant. If the new plant is built at the -th candidate site, its fixed annual operating cost is yuan, and the transportation cost per ton of raw coal from the -th mine to the -th candidate site is yuan.
Question: Which site should be selected for the new plant, and how should the raw coal from the mines be allocated to the two plants, so that the total annual cost (the sum of the plants’ operating costs and the coal transportation costs) is minimized?
Input Format
The first line contains four integers .
The next line contains integers , representing the annual output of each coal mine.
The next line contains integers , representing the fixed cost if the new plant is built at each candidate site.
The next lines each contain positive integers. The -th line describes the values of .
Output Format
The first line contains one integer, the index of the selected site for the new power plant. If multiple sites satisfy the condition, output the smallest index.
The second line contains one integer, the minimal total annual cost.
4 2 7 9
3 1 10 3
6 3 7 1 10 2 7 4 9
1 2 4 3
6 6 8 2
4 10 8 4
10 2 9 2
7 6 6 2
9 3 7 1
2 1 6 9
3 1 10 9
4 2 1 8
2 1 3 4
8
49
Hint
For of the testdata (Constraints): , , , , , , .
Translated by ChatGPT 5
京公网安备 11011102002149号