eolymp
bolt
Попробуйте наш новый интерфейс для отправки задач
Задачи

Globulous Gumdrops

Globulous Gumdrops

\includegraphics{https://static.e-olymp.com/content/4c/4c7d121df95af0fa8ec84918b729a0348869afc3.jpg} Gwen just bought a bag of gumdrops! However, she does not like carrying gumdrops in plastic bags; instead, she wants to pack her gumdrops in a cylindrical tube of diameter \textbf{d}. Given that each of her gumdrops are perfect spheres of radii \textbf{r_1}, \textbf{r_2}, ..., \textbf{r_n}, find the shortest length tube Gwen can use to store her gumdrops. You should assume that the gumdrop radii are sufficiently large that no three gumdrops can be simultaneously in contact with each other while fitting in the tube. Given this restriction, it may be helpful to realize that the gumdrops will always be packed in such a way that their centers lie on a single two-dimensional plane containing the axis of rotation of the tube. \InputFile The input file will contain multiple test cases. Each test case will consist of two lines. The first line of each test case contains an integer \textbf{n} (\textbf{1} ≤ \textbf{n} ≤ \textbf{15}) indicating the number of gumdrops Gloria has, and a floating point value \textbf{d} (\textbf{2.0} ≤ \textbf{d} ≤ \textbf{1000.0}) indicating the diameter of the cylindrical tube, separated by a space. The second line of each test case contains a sequence of n space-separated floating point numbers, \textbf{r_1} \textbf{r_2} ... \textbf{r_n} (\textbf{1.0} ≤ \textbf{r_i} ≤ \textbf{d/2}) are the radii of the gum drops in Gloria’s bag. A blank line separates input test cases. A single line with the numbers "\textbf{0 0}" marks the end of input; do not process this case. \textbf{Output} For each input test case, print the length of the shortest tube, rounded to the nearest integer.
Лимит времени 8 секунд
Лимит использования памяти 64 MiB
Входные данные #1
2 98.1789
42.8602 28.7622

3 747.702
339.687 191.953 330.811

0 0
Выходные данные #1
138
1628