// 刚开始,没想到神马好思路,原来这些fence全部都要用到,= =!,果断做了...
1 Source Code
2
3 Problem: 1948 User: eth1
4 Memory: 1372K Time: 125MS
5 Language: G++ Result: Accepted
6
7 Source Code
8 #include <iostream>
9 #include <algorithm>
10 #include <cstring>
11 #include <cmath>
12 using namespace std;
13 bool map[805][805];
14 int f[45];
15 bool check(int a,int b,int c)
16 {
17 if(a+b>c && a+c>b && b+c>a) return 1;
18 return 0;
19 }
20 int ans(int a,int b,int c)
21 {
22 double tem = (a+b+c)*1.0/2;
23 return (int)(sqrt(tem*(tem-a)*(tem-b)*(tem-c))*100);
24 }
25 int main()
26 {
27 int t,sum=0;
28 cin>>t;
29 for(int i=0;i<t;i++) {cin>>f[i];sum+=f[i];}
30 sort(f,f+t);
31 memset(map,0,sizeof(map));
32 map[0][0]=1;
33 for(int i=0;i<t;i++)
34 {
35 for(int j=sum/2;j>=0;j--)
36 {
37 for(int k=sum/2;k>=0;k--)
38 {
39 if( j>=f[i] && map[j-f[i]][k] || (k>=f[i] && map[j][k-f[i]]) )
40 map[j][k]=1;
41 }
42 }
43 }
44 int maxx=-1;
45 for(int i=sum/2;i>0;i--)
46 for(int j=sum/2;j>0;j--)
47 {
48 if(map[i][j])
49 {
50 int tem = sum-i-j;
51 if(check(tem,i,j))
52 {
53 maxx = max(maxx,ans(tem,i,j));
54 }
55 }
56 }
57 cout<<maxx<<endl;
58 return 0;
59 }
 posted on 2011-05-14 14:38  eth0  阅读(153)  评论(0编辑  收藏  举报