TopCoder problem "SymmetricPie" used in SRM 406 (Division I Level One)

Problem Statement

    You've collected data in a int[] dogs which describes how many dogs are present in each neighborhood of your city, and you wish to represent this data in a pie chart. The total number of dogs in your city is exactly 100, so if a neighborhood has 15 dogs, it will form a solid region in the chart with an area equal to 15% of the whole pie chart.

Given a pie chart, a dividing line is a line that passes through the center of the chart and doesn't pass through the interior of any solid region of the chart. For example, the chart on the left has two dividing lines, while the chart on the right has only one dividing line (see examples 0 and 1 for the data that forms these two charts).

Note that there may be several ways to create a pie chart from the same data. Return the maximum number of dividing lines in a pie chart that can be made from the data.


Method signature:int getLines(int[] dogs)
(be sure your method is public)


-dogs will contain between 1 and 8 elements, inclusive.
-Each element of dogs will be between 1 and 100, inclusive.
-The sum of all elements of dogs will be exactly 100.


Returns: 2
This is the left pie chart in the problem statement's diagram.
Returns: 1
This is the right pie chart in the problem statement's diagram.
Returns: 1
The only line here divides the chart through the center.
Returns: 3
The best solution here is to put the regions in the order (1,1,48,1,1,48), giving us 3 dividing lines.
Returns: 0

Problem url:

Problem stats url:




PabloGilberto , Olexiy , gawry , ivan_metelsky

Problem categories:

Brute Force