TopcoderArchiveVisit Topcoder
Archive
Algorithm problem

GameLocations

Problem statement, definition, constraints, and public examples.

Problem Statement

*** WARNING: Do not leave the competition room while you are competing. If you have a question, use "admins: question" in the chat area. ***

In running an arcade, just as in real estate, the key word is location. It turns out that the profitibility of a particular machine is proportional to the visibility of that machine from the entrance. You have a truckload of new machines coming in, and you have a number of places open in your venue to place these machines. You would like to place as many of these machines as possible in locations that would maximize your overall value. The profit of a machine at a location is the machine's potential times the percentage visibility from the entrance, thus a machine with a profibility of 530 and a visibility of 10 percent would vield a profit of 53.

Given a int[] of machinePotentials representing the profitability of each machine in the truckload coming in and a int[] of locationVisibilitys representing the percentage visibility of each available location from the entrance, return an int that represents the maximum profit that can be obtained from the best placement of the machines, rounded down.

Definition

Class:
GameLocations
Method:
maximizeProfits
Parameters:
int[], int[]
Returns:
int
Method signature:
int maximizeProfits(int[] machinePotential, int[] locationVisibility)
(be sure your method is public)

Notes

  • There may be more machines than locations.
  • There may be more locations than machines.
  • HINT: You can do this problem with integers... just make sure that you put off dividing by 100 until the very end.

Constraints

  • machinePotential will contain between 1 and 20 elements, inclusive.
  • locationVisibility will contain between 1 and 20 elements, inclusive.
  • Every element of machinePotential will be between 1 and 1000, inclusive.
  • Every element of locationVisibility will be between 0 and 100 inclusive.

Examples

  1. {10,20,30}
    {100}
    Returns: 30
    You only have one location available, so you'll stick the most profitable game in that location and store the other two games until a location becomes available.
  2. {100,80,100,80}
    {100,50,25}
    Returns: 170
    Your two 100s can take the positions with full visibility and 50 percent visibility, and you can stick one of the 80s into a 25 percent visibility location and the other 80 in storage. Result: (100*100+100*50+80*25)/100 or 170 would be the maximum amout of profit you could do.
  3. {100,200}
    {50,10,5}
    Returns: 110
    If you put the 200 in the 50% visibility spot and the 100 in the 10% visibility spot and leave the 5% visibility spot empty until the next shipment you'll have a maximum profitability of (200*50+100*10)/100 or 110 which is the best you can do.
  4. {800,500,200,300,400}
    {57,34,92,86}
    Returns: 1496
  5. {1000,1000,1000}
    {0}
    Returns: 0
    If the position isn't visible, there's no way that the machine will make a profit.
Back to all problems