| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
为什么是RE啊????大牛帮看看哈..#include<algorithm>
#include<math.h>
using namespace std;
int sum=0;
double judge(int a,int b)
{
int c;
c=sum-a-b;
if(c<=0)
return 0;
if(a>=b+c||b>=a+c||c>=a+b)
return 0;
double tt=(double)(a+b+c)/2.0;
return sqrt((double)tt*(tt-a)*(tt-b)*(tt-c));
}
bool cmp(double a,double b)
{
return a<b;
}
bool dp[1610][1610]={0};
main()
{
int n,i,j,k;
int aa[100];
double max=0.0,tem;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&aa[i]);
sum+=aa[i];
}
dp[0][0]=1;
for(i=0;i<n;i++)
{
for(j=sum;j>=0;j--)
{
for(k=(sum-j);k>=0;k--)
{
if(dp[j][k-aa[i]]==1&&k>=aa[i])
dp[j][k]=1;
if(dp[j-aa[i]][k]==1&&j>=aa[i])
dp[j][k]=1;
}
}
}
for(i=1;i<sum;i++)
{
for(j=1;j<sum;j++)
{
if(dp[i][j]==1)
{
tem=judge(i,j);
if(tem>max)
max=tem;
}
}
}
if(max==0.0)
printf("-1\n");
else
printf("%d\n",(int)(max*100));
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator