5909. 围出栅栏
SPJ
时间限制:1000 MS 内存限制:256 MB
题目描述
## 题目描述 There is a large grassland next to the villa Pemberley in the southern region of Byterland. Mrs. Darcy is afraid of her potted plants being trampled by strangers, so she decides to fence in some triangular areas in the grassland. Mrs. Darcy has several fences in her basement. She will form each triangular area using exactly three fences, such that each side of the triangle is a single fence. Since the fences are beautifully decorated, she will not glue multiple fences together to form a single side, or split a single fence into multiple smaller fences. Her goal is to fence in as large an area as possible. You are given a int[] fences containing the lengths of Mrs. Darcy's fences. Return the maximal area that can be fenced in. 在拜特兰南部地区的彭伯里别墅旁,有一片广阔的草地。达西夫人担心她的盆栽被陌生人踩踏,于是决定在草地上用栅栏围出一些三角形区域。 达西夫人的地下室里存放着几根栅栏。她会用恰好三根栅栏围出每一块三角形区域,三角形的每条边都由一根完整的栅栏构成。由于这些栅栏都装饰精美,她不会将多根栅栏拼接起来作为一条边,也不会把一根栅栏拆分成多段更短的栅栏使用。她的目标是围出面积尽可能大的区域。 给定一个整数数组fences,其中包含达西夫人拥有的所有栅栏的长度。请返回能够围出的最大区域面积。 ## 输入格式 Length of fences int[] fences ## 输出格式 double ### 样例 ## 输入 ```in1 7 3 4 5 6 7 8 9 ``` ## 输出 ```out1 36.754383146489694 ``` ## 说明 You can construct two triangles (3, 4, 5) and (7, 8, 9) with a total area of approximately 32.83 square meters. This is a preferable solution to constructing triangles (4, 5, 6) and (7, 8, 9), which have a total area of approximately 36.75 square meters. ```in2 4 1 2 4 8 ``` ```out2 0.0 ``` ## 说明 Can not form any triangle here. ```in3 4 7 4 4 4 ``` ```out3 6.928203230275509 ``` ## 说明 Duplicate elements in fences are allowed. ```in4 16 21 72 15 55 16 44 54 63 69 35 75 69 76 70 50 81 ``` ```out4 7512.322360676162 ``` ## 数据范围 - fences will contain between 1 and 16 elements, inclusive. - Each element of fences will be between 1 and 100, inclusive. ## 提示 - A return value with either an absolute or relative error of less than 1.0E-9 is considered correct. - With three fences of length A, B, and C, where A C. - The area of a triangle with side lengths A, B, and C is sqrt(p*(p-A)(p-B)(p-C)), where p = (A+B+C)/2."