CircleDance
SRM 244 · 2005-05-23 · by logged
Problem Statement
Constraints
- heights will contain between 3 and 20 elements inclusive.
- Each element of heights will be between 150 and 210 inclusive.
{180,183,178,185}
Returns: 5
The dancers may be arranged in a circle like this: 180 / \ 185 178 \ / 183 Their height differences are shown below: 180 (5)/ \(2) 185 178 (2)\ /(5) 183 The maximum difference is 5. Other arrangements may not lead to an optimal solution. For example, the following one has a maximum difference of 7: 180 (3)/ \(2) 183 178 (2)\ /(7) 185
{170,180,190}
Returns: 20
Any arrangement is equivalent to the following one: 180 (10)/ \(10) 170 - 190 (20) So the result is 20.
{180,180,180,180,180}
Returns: 0
{184,165,175,186,192,200,176,192,194,168,205,201}
Returns: 10
{155,192,169,162,174,155,180,184,150,180,192,198,199}
Returns: 14
Submissions are judged against all 46 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class CircleDance with a public method int arrangeDancers(vector<int> heights) · 46 test cases · 2 s / 256 MB per case