#P3265. [JLOI2015] 装备购买

[JLOI2015] 装备购买

Description

Lian Ge is playing a magical game. There are nn pieces of equipment, each with mm attributes, represented by a vector zi=(a1,,aj,,am)\mathbf{z_i} = (a_1, \ldots, a_j, \ldots, a_m) (1in1 \le i \le n, 1jm1 \le j \le m). Each piece of equipment costs cic_i. Lian Ge wants to buy some equipment, but he is poor, so he always tries to spend as little money as possible to buy as many pieces as possible. For him, if the attributes of one piece of equipment can be formed by a combination of other purchased equipment (that is, he can use the equipment he owns to reproduce the effect of this piece), then this piece is unnecessary to buy.

The strict definition is: if Lian Ge has bought zi1,,zip\mathbf{z_{i_1}}, \ldots, \mathbf{z_{i_p}}, then for any undecided zh\mathbf{z_h}, if there do not exist b1,,bpb_1, \ldots, b_p such that $b_1 \mathbf{z_{i_1}} + \ldots + b_p \mathbf{z_{i_p}} = \mathbf{z_h}$ (bib_i are real numbers), then Lian Ge will buy zh\mathbf{z_h}; otherwise, zh\mathbf{z_h} is useless to him and need not be purchased.

For example, let z1=(1,2,3)\mathbf{z_1} = (1, 2, 3), z2=(3,4,5)\mathbf{z_2} = (3, 4, 5), zh=(2,3,4)\mathbf{z_h} = (2, 3, 4), and b1=12b_1 = \frac{1}{2}, b2=12b_2 = \frac{1}{2}. Then b1z1+b2z2=zhb_1 \mathbf{z_1} + b_2 \mathbf{z_2} = \mathbf{z_h}. In this case, if Lian Ge buys z1\mathbf{z_1} and z2\mathbf{z_2}, he will not buy zh\mathbf{z_h}.

Lian Ge wants to spend the minimum cost while buying the maximum number of pieces of equipment. Can you help him compute the result?

Input Format

The first line contains two numbers n,mn, m.
The next nn lines each contain mm numbers; the ii-th line describes the attribute values of equipment ii.
The next line contains nn numbers, where cic_i is the cost of buying the ii-th piece of equipment.

Output Format

Output one line with two numbers: the maximum number of pieces that can be purchased, and the minimum total cost under that maximum.

3 3
1 2 3
3 4 5
2 3 4
1 1 2
2 2

Hint

As described in the problem, choosing equipment 11 and 22, equipment 11 and 33, or equipment 22 and 33 are all valid, but choosing equipment 11 and 22 has the minimum cost, which is 22.

For 100%100\% of the testdata, 1n,m5001 \le n, m \le 500, 0aj10000 \le a_j \le 1000.

Translated by ChatGPT 5