0-1背包-poj-1948-Triangular Pastures

简介: poj-1948-Triangular Pastures 携程大赛2014.4.11 预赛第二场第二题 Description Like everyone, cows enjoy variety. Their current fancy is new shapes for pastures. The old rectangular shapes are out of favor; n

poj-1948-Triangular Pastures

携程大赛2014.4.11 预赛第二场第二题

Description

Like everyone, cows enjoy variety. Their current fancy is new shapes for pastures. The old rectangular shapes are out of favor; new geometries are the favorite. 

I. M. Hei, the lead cow pasture architect, is in charge of creating a triangular pasture surrounded by nice white fence rails. She is supplied with N (3 <= N <= 40) fence segments (each of integer length Li (1 <= Li <= 40) and must arrange them into a triangular pasture with the largest grazing area. Ms. Hei must use all the rails to create three sides of non-zero length. 

Help Ms. Hei convince the rest of the herd that plenty of grazing land will be available.Calculate the largest area that may be enclosed with a supplied set of fence segments. 

Input

* Line 1: A single integer N 

* Lines 2..N+1: N lines, each with a single integer representing one fence segment's length. The lengths are not necessarily unique. 

Output

A single line with the integer that is the truncated integer representation of the largest possible enclosed area multiplied by 100. Output -1 if no triangle of positive area may be constructed. 

Sample Input

5

1

1

3

3

4

Sample Output

692

 大意:用给的几段篱笆围一个牛圈。所有篱笆必须全用上!输出能围成的最大的三角形牛圈。0-1背包DP问题。

代码:优化前后的两组

 

 

目录
相关文章
|
10月前
三对角矩阵(Triangular Matrix)
三对角矩阵(Triangular Matrix)是一种特殊形式的矩阵,其非零元素仅位于主对角线以及主对角线两侧的相邻对角线上。三对角矩阵在数学、工程和计算机科学等领域中都有广泛应用,特别是在线性代数中。以下是一些关于三对角矩阵的特点和应用:
572 6
|
10月前
|
机器学习/深度学习
下三角矩阵(Lower Triangular Matrix)
下三角矩阵(Lower Triangular Matrix)是一种特殊形式的矩阵,其非零元素仅位于主对角线以下。在数学和工程领域中,下三角矩阵通常用于线性代数和微积分等问题。以下是一些关于下三角矩阵的特点和应用:
945 1
|
10月前
|
机器学习/深度学习
上三角矩阵(Upper Triangular Matrix
上三角矩阵(Upper Triangular Matrix)是一种特殊形式的矩阵,其非零元素仅位于主对角线以上。在数学和工程领域中,上三角矩阵通常用于线性代数和微积分等问题。以下是一些关于上三角矩阵的特点和应用:
932 0
|
11月前
codeforces 339A.Helpful Maths B.Xenia and Ringroad 两水题
.题意就是把字符串里面的数字按增序排列,直接上代码。
36 0
UVa1584 - Circular Sequence
UVa1584 - Circular Sequence
32 0
UVa11549 - Calculator Conundrum (Floyd判圈法)
UVa11549 - Calculator Conundrum (Floyd判圈法)
44 0
|
人工智能
CodeForces-Kuroni and Impossible Calculation(思维+鸽巢原理)
CodeForces-Kuroni and Impossible Calculation(思维+鸽巢原理)
81 0
|
人工智能
codeforces859——C. Pie Rules(思维+DP)
codeforces859——C. Pie Rules(思维+DP)
104 0
|
算法
【欧拉计划第 12 题】 高度可除的三角数 Highly divisible triangular number
【欧拉计划第 12 题】 高度可除的三角数 Highly divisible triangular number
115 0
【欧拉计划第 12 题】 高度可除的三角数 Highly divisible triangular number
Triangular Collection思维
题目描述 Call a set of positive integers triangular if it has size at least three and, for all triples of distinct integers from the set, a triangle with those three integers as side lengths can be constructed. Given a set of positive integers, compute the number of its triangular subsets.
112 0