Statistics

Problem Statement for "ChallengePhase"

Problem Statement

PROBLEM STATEMENT

You are playing a single round match at TopCoder now. Currently you are
involved in the challenge phase. You checked all submitted problems and they
all are correct, except one problem: only UG830H submitted the 1000-point
problem and you immediately recognize the submission as incorrect. More
precisely, the problem was: given an integer, return "EVEN" if it is even, or
"ODD" if it is odd. UG830H wrote a program that uses a random number generator
to return "EVEN" or "ODD" randomly with the same probability. Of course, this
submission would fail the system test, but your chance of a successful
challenge is 50%. It would make sense to challenge if your gain (an increase in
prize money) for a successful challenge is bigger than your loss (decrease in
prize money) for an unsuccessful challenge. 

Your task is, given the scores of everybobody (an int[] of scores of everyone
other then you and your score (an int myScore) before the challenge) and prizes
for your room, return the difference between your gain if your challenge is
successful and your loss if your challenge is unsuccessful.

NOTES
- as usual, a successful challenge earns 50 points, an unsuccessful one loses
50 points
- assume that there is no tie for prizes before challenge and after either a
successful or an unsuccessful challenge
- there are three prizes: prizes[0] is third place prize, prizes[1] is second
place prize, prizes[2] is first place prize
- the elements of scores are final, they will not change as a result of your
challenge

DEFINITION
Class: ChallengePhase
Method: randomCode
Parameters: int[], int, int[]
Returns: int
Method signature (be sure your method is public):  int randomCode(int[] scores,
int myScore, int[] prizes);
 
TopCoder will ensure the validity of the inputs. Inputs are valid if all of the
following criteria are met:
- scores is an int[] of 9 final scores of your opponents
- each element of scores is between 0 and 2000 inclusive
- myScore is between 0 and 2000 inclusive
- prizes is an int[] of 3 integers matching prizes in dollars
- elements of prizes are given in ascending order
- each element of prizes is between 10 and 100 inclusive
- all three elements of prizes are different from each other
- there is no tie for prizes before challenge and after either a successful or
an unsuccessful challenge

EXAMPLES
1. scores = {0,0,0,0,0,0,50,100,150}; myScore = 49; prizes = {10,25,60};
without a challenge you receive 0, with a successful challenge you receive 10,
with an unsuccessful challenge you receive 0; hence your gain for a successful
challenge is 10, your loss for an unsuccessful challenge is 0, and you return
the difference: 10.

2. scores = {143,144,145,146,147,148,149,151,152}; myScore = 150; prizes =
{10,50,100}; without a challenge you receive 10, with a successful challenge
you receive 100, with an unsuccessful challenge you receive 0; hence your gain
for a successful challenge is 90, your loss for an unsuccessful challenge is
10, and you return the difference: 80.

3. scores = {143,144,145,146,147,148,149,151,152}; myScore = 350; prizes =
{10,50,100}; without a challenge you receive 100, with a successful challenge
you receive 100, with an unsuccessful challenge you receive 100; hence your
gain for a successful challenge is 0, your loss for an unsuccessful challenge
is 0, and you return the difference: 0.

4. scores = {743,644,545,446,1347,1248,1490,1510,1252}; myScore = 50; prizes =
{10,50,100}; without a challenge you receive 0, with a successful challenge you
receive 0, with an unsuccessful challenge you receive 0; hence your gain for a
successful challenge is 0, your loss for an unsuccessful challenge is 0, and
you return the difference: 0.

5. scores = {743,644,545,446,1347,1248,1490,1510,1752}; myScore = 1500; prizes
= {40,50,60}; without a challenge you receive 40, with a successful challenge
you receive 50, with an unsuccessful challenge you receive 0; hence your gain
for a successful challenge is 10, your loss for an unsuccessful challenge is
40, and you return the difference: -30.

Definition

Class:
ChallengePhase
Method:
randomCode
Parameters:
int[], int, int[]
Returns:
int
Method signature:
int randomCode(int[] param0, int param1, int[] param2)
(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: