CodeWa!
找到你要的答案

## Q：NxN matrix is given and we have to find |
## Q：n×n矩阵给出了我们必须找到 |

N things to select for N people, you were given a NxN matrix and cost at each element, you needed to find the one combination with max total weight, such that each person gets exactly one thing. I found difficulty in making its dp state. please help me and if possible then also write code for it |
n选择N人，你在每个单元给定一个n×n矩阵和成本，你需要找到一个结合的最大总重量，这样每个人得到一件事。 I found difficulty in making its dp state. please help me and if possible then also write code for it |

answer1： | 回答1： |

C++ style code:
Call max_comb with N and your NxN matrix (2d array). Returns the column indices of the maximum combination. Time complexity: O(N!) I know this is bad but the problem does not have a greedy structure. And as @mszalbach said, try to attempt the problem yourself before asking. EDIT: can reduce to polynomial time by memoizing. |
C++风格的代码：
打电话给你max_comb N和n×n矩阵（二维数组）。返回最大组合的列索引。 Time complexity: O(N!) I know this is bad but the problem does not have a greedy structure. 作为“mszalbach说，尝试自己之前问的问题。 编辑：可以减少通过memoizing多项式时间。 |

dynamic-programming |