Statistics

Problem Statement for "Award"

Problem Statement

PROBLEM STATEMENT

After many months of using a two-division competition structure, TopCoder
decides to revamp contest organization and needs your help to correctly compute
the prizes for a room under a new scheme.  Awards are to be calculated
individually for each room, based on the ratings of the coders in that room.
Your task is to compute the award for a sample room in a sample competition.

Based on a coder's rating, a certain number of prize pool shares are
contributed to that coder's room.  The prize pool, $2000 for purposes of this
problem, is then divided over the rooms according to the number of shares in
each room.  These amounts are further divided among the first, second, and
third place finishers of each room.  39% of the room prize pool is assigned to
first place, 33% is assigned to second place, and 28% is assigned to third
place (truncating any decimal part of the final result).

As input, you are given the ratings of eight coders (room 1).  Provided is an
array, otherRooms, that contains the ratings of coders in rooms 2 through 5.
Return the awards for room 1, putting the award for first place in the position
0, second place in position 1, and third place in position 2.

The number of shares a coder contributes to his room is denoted by:

10 ^ (coder_rating / 1900)

DEFINITION
Class: Award
Parameters: int[]
Returns: int[]
Method signature (be sure your method is public): int[] calculate(int[] ratings);

TopCoder will ensure the validity of the inputs.  Inputs are valid if all of
the following criteria are met:

* The input parameter must have exactly eight elements.
* The input parameter elements will be in the range 0 to 3500, inclusive.

EXAMPLES
[1400, 1500, 1600, 1700, 1800, 1850, 1900, 2000]

First calculate the number of shares the room gets:
10 ^ (1400 / 1900) = 10 ^ 0.736... = 5.45...
10 ^ (1500 / 1900) = 10 ^ 0.789... = 6.15...
10 ^ (1600 / 1900) = 10 ^ 0.842... = 6.95...
10 ^ (1700 / 1900) = 10 ^ 0.894... = 7.84...
10 ^ (1800 / 1900) = 10 ^ 0.947... = 8.85...
10 ^ (1850 / 1900) = 10 ^ 0.973... = 9.41...
10 ^ (1900 / 1900) = 10 ^ 1.000    =10.00
10 ^ (2000 / 1900) = 10 ^ 1.052... =11.28...
                                   =========
                                    65.97...

If you repeat this for the other rooms (see otherRooms), you'll find they get a
total of 172.86... shares.

Then: $2000 * 65.97... / (65.97... + 172.86...) = $552.44...

This is the amount awarded to the winners of room 1.  It is divided as follows:

1st place = $552.44... * 0.39 = $215
2nd place = $552.44... * 0.33 = $182
3rd place = $552.44... * 0.28 = $154

Thus, calculate should return [215, 182, 154].

[ 444,  444,  555,  666,  777,  888,  999, 1111], calculate should return [ 82,
 69,  58]
[2670, 2670, 2670, 2670, 2670, 2670, 2670, 2670], calculate should return [421,
356, 302]
[   0, 1995, 1098,  875, 1978,  713, 1932, 3500], calculate should return [306,
259, 220]

PROVIDED CODE
/* JAVA 
    int[][] otherRooms = { { 1200, 1200, 1200, 1200, 1200, 1200, 1200, 1200 } ,
                           {  314, 1592,  653,  589,  793, 2384,  626,  433 } ,
                           { 2718, 2818,  284,  590,  452,  353,  602,  874 } ,
                           { 1414, 2135,  623,  730,  950,   48,  801,  688 } };
*/
/* C++
  int otherRooms[4][8] = { { 1200, 1200, 1200, 1200, 1200, 1200, 1200, 1200 } ,
                           {  314, 1592,  653,  589,  793, 2384,  626,  433 } ,
                           { 2718, 2818,  284,  590,  452,  353,  602,  874 } ,
                           { 1414, 2135,  623,  730,  950,   48,  801,  688 } };
*/

Definition

Class:
Award
Method:
calculate
Parameters:
int[]
Returns:
int[]
Method signature:
int[] calculate(int[] param0)
(be sure your method is public)

Constraints

    Examples


      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)2024, TopCoder, Inc. All rights reserved.
      This problem was used for: