标签:
Description
Input
Output
Sample Input
5 1 1 3 3 4
Sample Output
692
Hint
#include<cstdio> #include<cstring> #include<cmath> #include<iostream> using namespace std; int dp[1000][1000]; int main(){ int n,res = 0,mx = -1; int a[50]; scanf("%d",&n); for(int i = 1; i <= n; i++){ scanf("%d", &a[i]); res+=a[i];} int half = res>>1; memset(dp,0,sizeof(dp)); dp[0][0] = 1; for(int i = 1; i <= n;i++) for(int j = half; j >=0;j--) for(int k = j; k >= 0; k--) if(j >= a[i]&&dp[j-a[i]][k]||k>=a[i]&&dp[j][k-a[i]])//得到可能性的边 dp[j][k] = 1; for(int i = half;i >= 1;i--){ for(int j = i;j >= 1;j--){ if(dp[i][j]){ int k = res - i - j; if(i+j>k && i+k>j&& k+j>i){ double p = 1.0*(j+k+i)/2; int S = (int)(sqrt(p*(p-i)*(p-j)*(p-k))*100); if(S>mx) mx = S; } } } } printf("%d",mx); return 0; }
标签:
原文地址:http://www.cnblogs.com/zero-begin/p/4313372.html