This problem is a water problem, then directly greedy on the past.
Multi-stage decision-making, in fact, should be used in DP, other people's code using vectors for preprocessing.
#include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #include <vector >using namespace Std;int N, a[12];d ouble dp[1<<12];d ouble cal (int a, int b, int c) {if (a+b<=c) return 0.0;double p = (a+b+c) *0.5;return sqrt (p* (p-a) * (p-b) * (P-C));} vector<int> V;int Main () {while (~SCANF ("%d", &n) && N) {memset (DP, 0, sizeof (DP)); for (int i=0; i<n; i + +) scanf ("%d", a+i); sort (A, a+n); V.clear (); for (int i=0, i<n; i++) {for (int j=i+1; j<n; J + +) {for (int k=j+1; k<n; k++) {int st = (1<<i) | ( 1<<J) | (1<<k);DP [St] = cal (A[i], a[j], a[k]); if (A[i]+a[j]>a[k]) v.push_back (ST);}}} for (int i=0; i< (1<<n), i++) {for (int j=0; j<v.size (); j + +) {if (I&v[j]) continue;dp[i| V[J]] = max (dp[i| V[J]], dp[i]+dp[v[j]]);}} printf ("%.2f\n", dp[(1<<n)-1]);} return 0;}
HDU 5135 Little Zu Chongzhi ' s triangles (state compression dp+vector)