Solves the assignment problem using the Hungarian algorithm.