

Problem Statement 
Contest:
Marathon Match 29
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 pointscore 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 (pointscore ^ 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 nonexample test cases.    The seeds for the examples are 110, in order.   Examples  0)    Locations = 179 Services = 7 Budget = 673
Services: Importance = 84, Cost = 83
 Importance = 70, Cost = 44
 Importance = 95, Cost = 16
 Importance = 56, Cost = 51
 Importance = 87, Cost = 85
 Importance = 45, Cost = 36
 Importance = 67, Cost = 19
 
 1)    Locations = 59 Services = 10 Budget = 1142
Services: Importance = 77, Cost = 36
 Importance = 19, Cost = 50
 Importance = 61, Cost = 23
 Importance = 33, Cost = 29
 Importance = 95, Cost = 58
 Importance = 72, Cost = 22
 Importance = 35, Cost = 50
 Importance = 44, Cost = 19
 Importance = 77, Cost = 91
 Importance = 28, Cost = 50
 
 2)    Locations = 145 Services = 10 Budget = 1520
Services: Importance = 41, Cost = 61
 Importance = 64, Cost = 23
 Importance = 76, Cost = 75
 Importance = 23, Cost = 60
 Importance = 28, Cost = 19
 Importance = 13, Cost = 14
 Importance = 55, Cost = 65
 Importance = 100, Cost = 36
 Importance = 91, Cost = 41
 Importance = 64, Cost = 79
 
 3)    Locations = 64 Services = 10 Budget = 1133
Services: Importance = 87, Cost = 31
 Importance = 78, Cost = 53
 Importance = 93, Cost = 15
 Importance = 44, Cost = 90
 Importance = 46, Cost = 60
 Importance = 65, Cost = 18
 Importance = 19, Cost = 78
 Importance = 74, Cost = 95
 Importance = 71, Cost = 15
 Importance = 85, Cost = 45
 
 4)    Locations = 87 Services = 7 Budget = 1275
Services: Importance = 74, Cost = 89
 Importance = 34, Cost = 71
 Importance = 31, Cost = 65
 Importance = 10, Cost = 46
 Importance = 37, Cost = 61
 Importance = 30, Cost = 16
 Importance = 87, Cost = 39
 
 5)    Locations = 155 Services = 13 Budget = 2153
Services: Importance = 97, Cost = 21
 Importance = 17, Cost = 39
 Importance = 55, Cost = 19
 Importance = 81, Cost = 54
 Importance = 66, Cost = 88
 Importance = 16, Cost = 77
 Importance = 32, Cost = 81
 Importance = 81, Cost = 22
 Importance = 54, Cost = 85
 Importance = 60, Cost = 53
 Importance = 13, Cost = 19
 Importance = 35, Cost = 88
 Importance = 36, Cost = 34
 
 6)    Locations = 194 Services = 12 Budget = 923
Services: Importance = 46, Cost = 38
 Importance = 96, Cost = 11
 Importance = 27, Cost = 39
 Importance = 92, Cost = 42
 Importance = 38, Cost = 26
 Importance = 58, Cost = 13
 Importance = 46, Cost = 90
 Importance = 49, Cost = 54
 Importance = 42, Cost = 50
 Importance = 68, Cost = 79
 Importance = 23, Cost = 87
 Importance = 53, Cost = 12
 
 7)    Locations = 152 Services = 10 Budget = 1259
Services: Importance = 70, Cost = 24
 Importance = 76, Cost = 91
 Importance = 41, Cost = 80
 Importance = 28, Cost = 38
 Importance = 63, Cost = 61
 Importance = 96, Cost = 29
 Importance = 72, Cost = 98
 Importance = 80, Cost = 77
 Importance = 30, Cost = 58
 Importance = 10, Cost = 64
 
 8)    Locations = 87 Services = 13 Budget = 2440
Services: Importance = 35, Cost = 73
 Importance = 12, Cost = 64
 Importance = 63, Cost = 96
 Importance = 92, Cost = 81
 Importance = 77, Cost = 49
 Importance = 46, Cost = 77
 Importance = 54, Cost = 80
 Importance = 76, Cost = 98
 Importance = 61, Cost = 90
 Importance = 83, Cost = 82
 Importance = 80, Cost = 10
 Importance = 32, Cost = 60
 Importance = 97, Cost = 51
 
 9)    Locations = 73 Services = 14 Budget = 1100
Services: Importance = 96, Cost = 66
 Importance = 87, Cost = 34
 Importance = 52, Cost = 90
 Importance = 100, Cost = 77
 Importance = 73, Cost = 22
 Importance = 100, Cost = 46
 Importance = 69, Cost = 27
 Importance = 48, Cost = 54
 Importance = 43, Cost = 98
 Importance = 31, Cost = 47
 Importance = 70, Cost = 92
 Importance = 38, Cost = 89
 Importance = 42, Cost = 57
 Importance = 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.

