-
Notifications
You must be signed in to change notification settings - Fork 1
/
TheJackpotDivTwo.html
6 lines (6 loc) · 3.69 KB
/
TheJackpotDivTwo.html
1
2
3
4
5
6
<html><body bgcolor="#ffffff" text="#000000"><table><tr><td colspan="2"><h3>Problem Statement</h3></td></tr><tr><td>    </td><td>John has recently won a jackpot, but he doesn't need the money. He decided to share it with his friends instead. He knows how much money each of his friends has, and he will use this information to perform the distribution. While he still has money left, he will repeat the following steps:
<ul>
<li>Choose the poorest friend. If there are multiple poorest friends, choose one of them randomly.</li>
<li>Give 1 dollar to the chosen friend.</li>
</ul>
You are given an int <b>jackpot</b>, the number of dollars John has won, and a int[] <b>money</b>, where the i-th element is the number of dollars currently owned by the i-th friend. Return a int[] containing the same number of elements as money. The return value must contain the number of dollars owned by each friend after John has performed the above distribution, sorted in non-decreasing order.</td></tr><tr><td colspan="2"><h3>Definition</h3></td></tr><tr><td>    </td><td><table><tr><td>Class:</td><td>TheJackpotDivTwo</td></tr><tr><td>Method:</td><td>find</td></tr><tr><td>Parameters:</td><td>int[], int</td></tr><tr><td>Returns:</td><td>int[]</td></tr><tr><td>Method signature:</td><td>int[] find(int[] money, int jackpot)</td></tr><tr><td colspan="2">(be sure your method is public)</td></tr></table></td></tr><tr><td>    </td></tr><tr><td></td></tr><tr><td colspan="2"><h3>Constraints</h3></td></tr><tr><td align="center" valign="top">-</td><td><b>money</b> will contain between 1 and 47 elements, inclusive.</td></tr><tr><td align="center" valign="top">-</td><td>Each element of <b>money</b> will be between 1 and 1,000,000, inclusive.</td></tr><tr><td align="center" valign="top">-</td><td><b>jackpot</b> will be between 1 and 1,000,000, inclusive.</td></tr><tr><td colspan="2"><h3>Examples</h3></td></tr><tr><td align="center" nowrap="true">0)</td><td></td></tr><tr><td>    </td><td><table><tr><td><table><tr><td><pre>{1, 2, 3, 4}</pre></td></tr><tr><td><pre>2</pre></td></tr></table></td></tr><tr><td><pre>Returns: {2, 3, 3, 4 }</pre></td></tr><tr><td><table><tr><td colspan="2">First, John will give one dollar to the first friend. Then he will give another dollar to the first or the second friend.</td></tr></table></td></tr></table></td></tr><tr><td align="center" nowrap="true">1)</td><td></td></tr><tr><td>    </td><td><table><tr><td><table><tr><td><pre>{4, 7}</pre></td></tr><tr><td><pre>1</pre></td></tr></table></td></tr><tr><td><pre>Returns: {5, 7 }</pre></td></tr><tr><td><table><tr><td colspan="2">Just one action here.</td></tr></table></td></tr></table></td></tr><tr><td align="center" nowrap="true">2)</td><td></td></tr><tr><td>    </td><td><table><tr><td><table><tr><td><pre>{1}</pre></td></tr><tr><td><pre>100</pre></td></tr></table></td></tr><tr><td><pre>Returns: {101 }</pre></td></tr><tr><td><table><tr><td colspan="2">Just one friend here.</td></tr></table></td></tr></table></td></tr><tr><td align="center" nowrap="true">3)</td><td></td></tr><tr><td>    </td><td><table><tr><td><table><tr><td><pre>{21, 85, 6, 54, 70, 100, 91, 60, 71}</pre></td></tr><tr><td><pre>15</pre></td></tr></table></td></tr><tr><td><pre>Returns: {21, 21, 54, 60, 70, 71, 85, 91, 100 }</pre></td></tr><tr><td></td></tr></table></td></tr></table><p>This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2003, TopCoder, Inc. All rights reserved. </p></body></html>