User:Jeff/Zones

Analysis
Given n towers, we must find the subset of a specified size with the greatest value, using a lexicographical tiebreaker rule. Since n is at most 20, we can generate and test each possibility using bitmasks. Therefore, this problem reduces to calculating the number of customers that would be served by a specific subset of towers.

To see how we might calculate this number, let's use the example diagram to calculate the number of customers served by towers 1, 2 and 3. Counting the individual regions by hand yields 5+7+8+3+2+15+5=45 total customers. If we were to simply sum the totals for each tower, we would get 15+20+25=60 customers. However, this number includes the regions of size 7 and 2 twice each, and the region of size 3 three times. By subtracting these extra additions, we get 60-7-2-3-3=45, the previously calculated answer. This algorithm can be generalized as follows: for each tower in the set we're considering building, add up the total number of customers it serves. Then, for each common service area, count the number of considered towers it includes (call this number x). If x > 1, we multiply the number of customers in this common service area by (x-1), which is the number of extra times these people have been counted, and subtract this product from our total.