JOIN Problem Statement

Problem: ServiceFacilities

### Problem Statement

You are working on developing a planned city, meaning that you intend to plan and build certain elements of the infrastructure, like services, even before people take up residence. Several points of interest where development is planned, have been mapped.

It now needs to be determined where to build different types of major services, which might include things like airports, schools, hospitals, recycling centers, etc. The goal is to minimize the (Euclidean) distance someone might have to travel in order to reach any of these services. Each different service has been assigned a level of importance, and has an associated cost to build. Any service may be placed at as many locations as you like, within the constraints of your budget, however each service must be placed on at least one location, and no point of interest can contain more than one service.

Your method will be called, and will be given several parameters. int[]s x and y indicate each of the points of interest. You will also be given int[] serviceImportance, where each element indicates the importance of that service, as well as int[] serviceCost indicating the cost of building each service. Finally, int budget indicates the maximum total expenditure.

Test cases will be generated as follows (all ranges uniform):

• Select the number of points, N = 50...200
• Select the number of services, S = 4...15
• Select N lattice points in the range (0, 0) - (100, 100)
• Select each service imporance in the range 10...100
• Select each service cost in the range 10...100
• Select budget in the range minCost...(4*minCost), where minCost is the cost of building each service exactly once

For a proposed set of service locations, the overall convenience is scored by considering each lattice point (x,y) in the range (0,0) - (100,100), inclusive. For each point, we calculate a point-score by taking the sum over all i of serviceImportance[i] * distance[i], where distance[i] is the Euclidean distance from (x,y) to the nearest service of type i. The overall score is then calculated as the mean value of (point-score ^ 2).

Your return should be an array of integers, where each pair of integers represents a service type and a service location. For instance, return[2 * i] is a service number, and return[2 * i + 1] is a location (refering to the index of x and y).

Your goal is to place services in each location as to obtain an overall convenience score as low as possible. The overall scoring will be relative, so you will get BEST/YOU points for each test case, where BEST is the best score on that test case, and YOU is your score on that test case.

A visualizer is available.

### Definition

 Class: ServiceFacilities Method: placeServices Parameters: int[], int[], int[], int[], int Returns: int[] Method signature: int[] placeServices(int[] x, int[] y, int[] serviceImportance, int[] serviceCost, int budget) (be sure your method is public)

### Notes

-Time limit is 20 seconds, and memory limit is 1GB.
-There are 100 non-example test cases.
-The seeds for the examples are 1-10, in order.

### Examples

0)

`Locations = 179Services = 7Budget = 673Services:Importance = 84, Cost = 83Importance = 70, Cost = 44Importance = 95, Cost = 16Importance = 56, Cost = 51Importance = 87, Cost = 85Importance = 45, Cost = 36Importance = 67, Cost = 19`
1)

`Locations = 59Services = 10Budget = 1142Services:Importance = 77, Cost = 36Importance = 19, Cost = 50Importance = 61, Cost = 23Importance = 33, Cost = 29Importance = 95, Cost = 58Importance = 72, Cost = 22Importance = 35, Cost = 50Importance = 44, Cost = 19Importance = 77, Cost = 91Importance = 28, Cost = 50`
2)

`Locations = 145Services = 10Budget = 1520Services:Importance = 41, Cost = 61Importance = 64, Cost = 23Importance = 76, Cost = 75Importance = 23, Cost = 60Importance = 28, Cost = 19Importance = 13, Cost = 14Importance = 55, Cost = 65Importance = 100, Cost = 36Importance = 91, Cost = 41Importance = 64, Cost = 79`
3)

`Locations = 64Services = 10Budget = 1133Services:Importance = 87, Cost = 31Importance = 78, Cost = 53Importance = 93, Cost = 15Importance = 44, Cost = 90Importance = 46, Cost = 60Importance = 65, Cost = 18Importance = 19, Cost = 78Importance = 74, Cost = 95Importance = 71, Cost = 15Importance = 85, Cost = 45`
4)

`Locations = 87Services = 7Budget = 1275Services:Importance = 74, Cost = 89Importance = 34, Cost = 71Importance = 31, Cost = 65Importance = 10, Cost = 46Importance = 37, Cost = 61Importance = 30, Cost = 16Importance = 87, Cost = 39`
5)

`Locations = 155Services = 13Budget = 2153Services:Importance = 97, Cost = 21Importance = 17, Cost = 39Importance = 55, Cost = 19Importance = 81, Cost = 54Importance = 66, Cost = 88Importance = 16, Cost = 77Importance = 32, Cost = 81Importance = 81, Cost = 22Importance = 54, Cost = 85Importance = 60, Cost = 53Importance = 13, Cost = 19Importance = 35, Cost = 88Importance = 36, Cost = 34`
6)

`Locations = 194Services = 12Budget = 923Services:Importance = 46, Cost = 38Importance = 96, Cost = 11Importance = 27, Cost = 39Importance = 92, Cost = 42Importance = 38, Cost = 26Importance = 58, Cost = 13Importance = 46, Cost = 90Importance = 49, Cost = 54Importance = 42, Cost = 50Importance = 68, Cost = 79Importance = 23, Cost = 87Importance = 53, Cost = 12`
7)

`Locations = 152Services = 10Budget = 1259Services:Importance = 70, Cost = 24Importance = 76, Cost = 91Importance = 41, Cost = 80Importance = 28, Cost = 38Importance = 63, Cost = 61Importance = 96, Cost = 29Importance = 72, Cost = 98Importance = 80, Cost = 77Importance = 30, Cost = 58Importance = 10, Cost = 64`
8)

`Locations = 87Services = 13Budget = 2440Services:Importance = 35, Cost = 73Importance = 12, Cost = 64Importance = 63, Cost = 96Importance = 92, Cost = 81Importance = 77, Cost = 49Importance = 46, Cost = 77Importance = 54, Cost = 80Importance = 76, Cost = 98Importance = 61, Cost = 90Importance = 83, Cost = 82Importance = 80, Cost = 10Importance = 32, Cost = 60Importance = 97, Cost = 51`
9)

`Locations = 73Services = 14Budget = 1100Services:Importance = 96, Cost = 66Importance = 87, Cost = 34Importance = 52, Cost = 90Importance = 100, Cost = 77Importance = 73, Cost = 22Importance = 100, Cost = 46Importance = 69, Cost = 27Importance = 48, Cost = 54Importance = 43, Cost = 98Importance = 31, Cost = 47Importance = 70, Cost = 92Importance = 38, Cost = 89Importance = 42, Cost = 57Importance = 93, Cost = 90`

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)2010, TopCoder, Inc. All rights reserved.