从低端向上,每个结点取下一层左右结点最大值和本身价值相加,dp[0][0]为最后结果 #include<iostream> #include<algorithm> #include<cstdio> using namespace std; #define MAXN 510 typedef long long LL; LL a[MAXN][MAXN],dp[MAXN][MAXN]; LL sum = ,level; int main() { int i,j; scanf(…
比如a[]={2,4,5,6,7},得出的两组数{2,4,6}和{5,7},abs(sum(a1)-sum(a2))=0: 比如{2,5,6,10},abs(sum(2,10)-sum(5,6))=1,所以得出的两组数分别为{2,10}和{5,6}. vector<int> vct; int last = INT_MAX; int halfOfSum(int* arr, int len) { int sum = 0; for (int i = 0; i < len; ++i) { sum…