title: How to allocate x copy of n objects among k persons
body: <p>I have following use case;</p>
  
  <p>I have N distinct items , each can have x number of copies. Now I need to distribute these items among k persons where each person's capacity is varying and can be &lt;=N.</p>
  
  <p>Following conditions must be met;</p>
  
  <p>Each person should get one and only one copy of an Item</p>
  
  <p>Example:</p>
  
  <pre><code>Items = apple , banana , orange
  copies = 3 ( It means we have 3 apples , 3 bananas and 3 oranges )
  So I have a array;
  {1,2,3,4,5,6,7,8,9} // 1,2,3 = 3 apples ; 4,5,6 = 3 banana ; 7,8,9 = 3 oranges
  Total Person = 5
  Person     Capacity
  P1         3
  P2         2
  P3         1
  P4         1
  P5         2
  </code></pre>
  
  <p>How can I solve such problem ? The problem I am facing is that when I allocate it for an arbitrary numbers for N , x , k , I sometimes end up in a case where I am left with some items to allocate because I can't ensure the condition that "Each person should get one and only one copy of an Item"</p>