A team lead has
Find the minimum total fatigue cost.
The twist: assigning the cheapest task to the current intern can steal the best task from a later intern.
The first line contains an integer KaTeX can only parse string typed expression.
The next KaTeX can only parse string typed expression lines contain KaTeX can only parse string typed expression integers each. The value in row KaTeX can only parse string typed expression and column KaTeX can only parse string typed expression is the cost of assigning intern KaTeX can only parse string typed expression to task KaTeX can only parse string typed expression.
Print a single integer — the minimum possible total fatigue cost.
Input
3
9 2 7
6 4 3
5 8 1Output9ExplanationOne optimal assignment is intern 1 to task 2, intern 2 to task 1, and intern 3 to task 3.
Example 2:
Input
2
5 1
2 4Output3