401827: GYM100534 J Bimetallic coins

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

J. Bimetallic coinstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

King Coin IV loves bi-metallic coins. Bi-metallic coins are coins consisting of two different alloys, arranged with an outer ring around a contrasting center. After consulting with the most prominent metallurgists, the king decided to abolish simple coins and increase the use of bi-metallic coins in his country.

They have n types of metals. Their technology allows them to mix two different basic metals in equal ratio and produce an alloy. Experienced metallurgists discovered that each alloy has a different thermal area expansion coefficient. For two different alloys, these coefficients help them to determine which one can be used as outer ring in a bi-metallic coin. An alloy can be used as outer ring if its thermal coefficient is less than thermal coefficient of inner part. For each alloy they know the costs to create an outer ring and inner part using that alloy. Because it's very expensive to make a revolution in mediums of exchanges in a country, the king wants to have maximum types of bi-metallic coins with minimum production cost. Note that each alloy can not be used in more than one type of bi-metallic coin.

Input

First line contains an integer n (3 ≤ n ≤ 50) — the number of basic metals. Following 3n lines describe three n × n matrices C, I, O. C consists of real numbers with exactly three digits after the decimal point. Ci, j is thermal area expansion coefficient of alloy composed by metals i and j.

I consists of integers. Ii, j is cost of creating an inner part from alloy composed by metals i and j. (1 ≤ Ii, j ≤ 10000)

O consists of integers. Oi, j is cost of creating an outer ring from alloy composed by metals i and j. (1 ≤ Oi, j ≤ 10000)

C, I, O are symmetric and their diagonals are always zero.

Output

Output two space separated integers in a single line. The maximum number of bi-metallic coin types and the minimum cost of producing these types while each alloy can not be used in more than one type.

ExamplesInput
3
0.000 0.012 0.312
0.012 0.000 0.111
0.312 0.111 0.000
0 3 5
3 0 4
5 4 0
0 4 9
4 0 5
9 5 0
Output
1 8

加入题单

算法标签: