PAYING UP Problem http://www.codechef.com/problems/MARCHA1/

#include
#include<stdlib.h>
#include
#include
#include
#include<stdlib.h>
using namespace std;
void check(int *input, long int m, long int size)
{
long int n=(pow(2.0,size)-1);
long int j=n;
long int flag=0;
while(j>0)
{
n=j;
long int sum=0;
long int i=size-1;
flag=0;
while(n>0)
{
if(n%2)
sum+=input[i];
i-=1;
n/=2;
if(sum==m)
{
flag=1;
break;
}
}
if(flag==1)
{
cout<<“Yes”;
break;
}
j-=1;
}
if(flag==0)
cout<<“No”;
}

int main ()
{
long int T,M,N;
int input;
cin>>T;
while(T)
{
cin>>N >> M;
input=(int
)malloc(sizeof(int)*N);
for(int i=0; i<N; i++)
cin>>input[i];
check(input,M,N);
T-=1;
}
return 0;
}

I dont know why but WA is showing up. I have tried many test cases and end cases . Please help.!

Hi @srinathkattula! I haven’t checked your logic but assuming that your logic is correct, the problem is with your output format. You have to print “Yes” or “No” on separate lines, so you should be using endl after each output to make it print on different lines. If there are any other logical errors, you can refer to the submitted solutions on the problem page.