If I have 100 apples at different weights, how do I share them out between a given number of people to a given ratio, so that each has as close as possible the same average weight per apple.

For example - 3 people require 20, 30 and 50 apples respectively. There are 100 apples of various known weights.

The average weight of each persons apples needs to be as close as possible.

I am afraid I don't know which branch of maths this falls under. Any help appreciated!