Minimal price

You have nn tasks to do, and nn workers that can do them. For each task 1in1 \le i \le n and each worker 1jn1 \le j \le n, p[i][j]p[i][j] is the price that the worker ii does the task jj.

Write a program that computes the minimal price of assigning exactly one different task to each worker.

Input

Input consists of a natural 1n101 \le n \le 10, followed by pp, the matrix n×nn \times n of prices (nn lines with nn natural numbers between 1 and 1000).

Output

Your program must print the minimal price of assigning exactly one different task to each worker.

Observation

There are algorithms of polynomial cost to solve this problem, but are difficult to program. Implement a backtracking.

Problem information

Author: Unknown
Translator: Carlos Molina

Generation: 2026-01-25T10:07:32.327Z

© Jutge.org, 2006–2026.
https://jutge.org