Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
149277 | 吴悠 | 三角形 | C++ | 通过 | 100 | 13 MS | 1064 KB | 856 | 2024-05-26 12:26:42 |
#include<iostream> #include<cmath> using namespace std; int ed[41]; bool dp[801][801]; bool judge(int a,int b,int c){ if(a+b>c && a+c>b && b+c>a){ return true; } else return false; } double S(int a,int b,int c){ double p=(a+b+c)*1.0/2; return sqrt(p*(p-a)*(p-b)*(p-c)); } int main(){ int n,sum=0; double maxs=0; cin>>n; for(int i=1;i<=n;i++){ cin>>ed[i]; sum+=ed[i]; } dp[0][0]=true; for(int i=1;i<=n;i++){ for(int a=sum/2;a>=0;a--){ for(int b=sum/2;b>=0;b--){ if((ed[i]<=a && dp[a-ed[i]][b]==true) || (ed[i]<=b && dp[a][b-ed[i]]==true)){ dp[a][b]=true; } } } } for(int a=1;a<=sum/2;a++){ for(int b=1;b<=sum/2;b++){ int c=sum-a-b; if(c>0 && dp[a][b]==true && judge(a,b,c)==true){ maxs=max(maxs,S(a,b,c)); } } } cout<<int(maxs*100)<<endl; return 0; }