- #1
robertjordan
- 71
- 0
Hi,
Let W be the sum of all the people's weights, let P be the total number of pizza slices available.
If:
If w1, w2, ... , wn are the weights of the n people, and a1, a2, ... , an are the numbers of slices each of the n people get (where each ai is a whole number >= 0), I want to find the set {a1, ... , an} such that:
∑ni = 1| ai/P - wi/W |
is minimized.
Is there a formula (some uses of ceiling, floor?) or algorithm to find this set {a1, ... , an} ?
Let W be the sum of all the people's weights, let P be the total number of pizza slices available.
If:
- I have P slices of pizza (P<=W)
- I have n people I want to split the pizza with
- I want to use people's weight to determine how many slices they get (more weight -> more slices)
- I don't want to split any slices. (I want to leave all slices whole)
- A person cannot eat more slices than the value of their weight. (ai<=wi)
If w1, w2, ... , wn are the weights of the n people, and a1, a2, ... , an are the numbers of slices each of the n people get (where each ai is a whole number >= 0), I want to find the set {a1, ... , an} such that:
∑ni = 1| ai/P - wi/W |
is minimized.
Is there a formula (some uses of ceiling, floor?) or algorithm to find this set {a1, ... , an} ?
Last edited: