m sockets and the right one has n, with m ≥ n. A cable between left socket i and right socket j costs price[i][j].
You may run any number of cables, and one socket may take several of them. Every socket on both panels must end up with at least one cable.
Return the minimum total cost of such wiring.price=[[4, 1], [2, 7]] → 3
Connect left socket 0 to right socket 1 (1) and left socket 1 to right socket 0 (2): 3 in total.
price=[[3], [5], [1]] → 9
There is a single right socket, and every left socket has to connect to it: 3 + 5 + 1 = 9.
price=[[2, 9, 4], [5, 1, 8], [6, 6, 3]] → 6
Cables along the diagonal: 2 + 1 + 3 = 6. It cannot be cheaper, since that is the sum of the cheapest cable for each right socket.
price=[[4, 1], [2, 7]]
3
Run checks the first 3 tests in your browser. Submit checks all 9 tests on the server, hidden ones included.