#include <stdio.h>
#include <string.h>
int input[21],used[21];
int dfs(int side,int nowside,int M,int time){
int i;
if (nowside==0){
time++;
nowside=side;
}
if (time==3)return 1;
for (i=M;i>=1;i--){
if (used[i])continue;
if (input[i]>nowside)continue;
if (input[i]>side)return 0;
if (input[i]<=side){
used[i]=1;
if (dfs(side,nowside-input[i],M,time)==1)return 1;
else {
used[i]=0;
continue;
}
}
}
return 0;
}
int main(){
int N,M,i,j,s,side,t,sum=0;
scanf("%d",&N);
for (i=1;i<=N;i++){
scanf("%d",&M);
sum=0;
for (j=1;j<=M;j++){
scanf("%d",&input[j]);
used[j]=0;
sum+=input[j];
}
if (sum%4!=0){
printf("no\n");
continue;
}
side=sum/4;
for (j=M-1;j>=1;j--){
for (s=1;s<=j;s++){
if (input[s]>input[s+1]){
int k=input[s];
input[s]=input[s+1];
input[s+1]=k;
}
}
}
if (dfs(side,side,M,0)==1)printf("yes\n");
else printf("no\n");
}
return 0;
}
這樣能過嗎?為何吃TLE