标签:
Time Limit: 1000MS | Memory Limit: 30000K | |
Total Submissions: 6783 | Accepted: 2201 |
Description
Input
Output
Sample Input
5 1 1 3 3 4
Sample Output
692
Hint
#include<iostream> #include<cstdio> #include<cstring> #include<string> #include<cmath> #include<algorithm> #include<cstdlib> using namespace std; int n,a[50],dp[810][810],sum,p,ans=-1; int main() { memset(dp,0,sizeof(dp)); scanf("%d",&n); dp[0][0]=1; for(int i=1;i<=n;i++) scanf("%d",&a[i]),sum+=a[i]; for(int i=1;i<=n;i++) { for(int j=sum/2;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=sum/2;i>=1;i--) { for(int j=i;j>=1;j--) { if(dp[i][j]) { int k=sum-i-j; double p=sum*1.0/2; if(i+j>k&&i+k>j&k+i>j) { int temp=(int)(sqrt(p*(p-i)*(p-j)*(p-k))*100); if(temp>ans) ans=temp; } } } } printf("%d\n",ans); return 0; }
标签:
原文地址:http://www.cnblogs.com/a972290869/p/4265517.html