I solved PAYING UP problem on codechef. Here is the entire code. But, its showing wrong answer. Kindly help me to resolve what error m I making
#include<bits/stdc++.h>
using namespace std;
int main()
{
int tc;
cin>>tc;
while(tc–)
{
int n,m;
cin>>n>>m;
vectorv;
bool check=false;
for(int i=0;i<n;i++)
{
int x;
cin>>x;
if(x>1000)
check=true;
v.push_back(x);
}
if(n>20 || check==true)
{
cout<<"NO"<<endl;
continue;
}
long long int range=(1<<n)-1;
bool flag=false;
for(long long int i=range;i>=0;i--)
{
long long int no=i;
int j=n-1;
int sum=0;
while(no>0)
{
if(no&1)
sum+=v[j];
j--;
no=no>>1;
}
if(sum==m)
{
flag=true;
//break;
}
}
if(flag)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
}
}