Suppose that I have N bags, each containing balls of a unique colour. What is the maximum number of pairs I can form without replacing the balls back in the bags and with the following constraints: 1)A pair cannot contain balls of the same colour(i.e from the same bag) 2)There cannot be more than one combination of 2 colours i.e if there's already a pair of red and black balls there cannot be another pair of the aforementioned colours .
My question is whether there's a simple method/formula to solve the above problem. I've also noticed that it strangely resembles the graph theory problem of proving that a degree sequence is graphical or not( which can be solved by the Havel-Hakimi algorithm)...