#include <bits/stdc++.h>
#define pb push_back
#define MAX 10006
#define mod 1000000009
#define read freopen("input.txt","r",stdin);
#define base 10
using namespace std;
typedef long long ll;
typedef unsigned long long llu;
int n,len,s;
vector<int>ary;
int dp[22][4002];
bool call(int i,int sum)
{
if(sum==(s-sum)) return 1;
if(dp[i][sum]!=-1) return dp[i][sum];
if(i>=len) return 0;
return dp[i][sum]=call(i+1,sum+ary[i])||call(i+1,sum);
}
int main()
{
// read;
int test;
scanf("%d",&test);
getchar();
while(test--)
{
ary.clear();
// flag=false;
string str;
getline(cin,str);
stringstream st;
st<<str;
s=0;
while(st>>n) ary.pb(n),s+=n;
memset(dp,-1,sizeof(dp));
len=ary.size();
puts(call(0,0)==1?"YES":"NO");
}
return 0;
}
#define pb push_back
#define MAX 10006
#define mod 1000000009
#define read freopen("input.txt","r",stdin);
#define base 10
using namespace std;
typedef long long ll;
typedef unsigned long long llu;
int n,len,s;
vector<int>ary;
int dp[22][4002];
bool call(int i,int sum)
{
if(sum==(s-sum)) return 1;
if(dp[i][sum]!=-1) return dp[i][sum];
if(i>=len) return 0;
return dp[i][sum]=call(i+1,sum+ary[i])||call(i+1,sum);
}
int main()
{
// read;
int test;
scanf("%d",&test);
getchar();
while(test--)
{
ary.clear();
// flag=false;
string str;
getline(cin,str);
stringstream st;
st<<str;
s=0;
while(st>>n) ary.pb(n),s+=n;
memset(dp,-1,sizeof(dp));
len=ary.size();
puts(call(0,0)==1?"YES":"NO");
}
return 0;
}
কোন মন্তব্য নেই:
একটি মন্তব্য পোস্ট করুন