#P2514. [HAOI2010] 工厂选址

[HAOI2010] 工厂选址

Description

There are mm coal mines in a region, where the ii-th mine produces aia_i tons per year. There is an existing thermal power plant that requires exactly bb tons of coal per year. Its fixed annual operating cost (excluding coal transportation) is hh yuan. The transportation cost per ton of raw coal from the ii-th mine to the existing plant is Ci,0C_{i,0} yuan.

A new power plant is planned to be built. All raw coal mined from the mm mines will be entirely supplied to these two power plants. There are nn candidate sites for the new plant. If the new plant is built at the jj-th candidate site, its fixed annual operating cost is hjh_j yuan, and the transportation cost per ton of raw coal from the ii-th mine to the jj-th candidate site is Ci,jC_{i,j} yuan.

Question: Which site should be selected for the new plant, and how should the raw coal from the mm 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 m,b,h,nm, b, h, n.

The next line contains mm integers a1,a2,,ama_1, a_2, \ldots, a_m, representing the annual output of each coal mine.

The next line contains nn integers h1,h2,,hnh_1, h_2, \ldots, h_n, representing the fixed cost if the new plant is built at each candidate site.

The next n+1n+1 lines each contain mm positive integers. The ii-th line describes the values of C1,i1,C2,i1,,Cm,i1C_{1,i-1} , C_{2,i-1} , \ldots , C_{m , i-1}.

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 100%100 \% of the testdata (Constraints): 1m5×1041 \leq m \leq 5 \times 10^4, 1b1041 \leq b \leq 10^4, 1n501 \leq n \leq 50, 0h,hi1000 \leq h , h_i \leq 100, 0ai5000 \leq a_i \leq 500, i=1maib\sum\limits_{i=1}^m a_i \geq b, 0Ci,j500 \leq C_{i,j} \leq 50.

Translated by ChatGPT 5