标签:bsp cto 分享 int -- ace res std nbsp
--正文
和宝藏分配差不多的思路,直接就这么写了,不过应该有更好的思路
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <queue> #include <vector> using namespace std; int f[10001]; int main(){ int time,T; scanf("%d",&T); for (time=1;time<=T;time++){ int n,i,j; int L[101],sum = 0; scanf("%d",&n); for (i=1;i<=n;i++){ scanf("%d",&L[i]); sum += L[i]; } int SIZE = sum / 2; memset(f,0,sizeof(f)); for (i=1;i<=n;i++){ for (j=SIZE;j>=L[i];j--){ f[j] = max(f[j-L[i]]+L[i],f[j]); } } int res = sum - 2*f[SIZE]; // printf("%d %d\n",sum,f[SIZE]); if (res != 0) { printf("No\n"); } else { printf("Yes\n"); } } return 0; }
标签:bsp cto 分享 int -- ace res std nbsp
原文地址:http://www.cnblogs.com/ToTOrz/p/6130159.html