#include <cstdio>
#include <algorithm>
using namespace std;
int l,i,j,k,m,n,maxx,a[30],vis[30];
int dfs(int line,int num,int len){
if(line==3)
return 1;
for(i=num-1;i>=1;i--){
if(vis[i]==0){
vis[i]=1;
if(a[i]+len<l)
if(dfs(line,i,a[i]+len))
return 1;
if(a[i]+len==l){
if(dfs(line+1,m,0))
return 1;
}
vis[i]=0;
}
}
}
int main(){
scanf("%d",&n);
for(j=1;j<=n;j++){
maxx=0;
k=0;
scanf("%d",&m);
for(i=0;i<=29;i++){
a[i]=0;
vis[i]=0;
}
for(i=1;i<=m;i++){
scanf("%d",&a[i]);
if(a[i]>maxx)
maxx=a[i];
k+=a[i];
}
l=k/4;
if(l*4!=k || maxx>l){
puts("no");
continue;
}
sort(a+1,a+n+1);
if(dfs(0,m,0))
puts("yes");
else
puts("no");
}
return 0;
}
POJ 2362
最新推荐文章于 2019-01-11 00:39:32 发布