2 ms·
The problem of finding the gift allocation with the highest sum of preferences is known as the Assignment Problem, a.k.a. finding a maximum-weight matching in a
by akoboldfrying 3y ago
The problem of finding the gift allocation with the highest sum of preferences is known as the Assignment Problem, a.k.a. finding a maximum-weight matching in a bipartite graph. Although brute force takes time proportional to the factorial of the number of players, this problem can be solved optimally in O(n^3) time using the Hungarian Algorithm: https://en.wikipedia.org/wiki/Hungarian_algorithm https://en.wikipedia.org/wiki/Hungarian_algorithm. This would mean you could optimally solve instances with a few hundred players.