Paying Up(MARCHA1) Wrong Answer

This is my solution link Solution

#include <stdio.h>;
#include ;
using namespace std;

void countsort(int k[],int maxim, int ksize);
bool searcher(int ks[],int tobesearched,int start);

int main(){
int testcases,n,m,input;
scanf("%d",&testcases);
while(testcases–){
scanf("%d%d",&n,&m);

    int t=0,tempres=0;
    int A[20] = {1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001};
    for(int dfs=0;dfs<n;dfs++){
        scanf("%d",&input);
        if(input==m){tempres=1;}
        if(input<m){
         A[t]=input;
         t++;
        }
    }
    if(m==0){cout << "Yes" << endl;}else{
    if(t==0){cout << "No" << endl;}else{
    if(tempres==1){cout << "Yes" << endl;}
    else{
    countsort(A,1001,20);

    if(searcher(A,m,t-1)==true){cout << "Yes" << endl;}else{cout << "No" << endl;}

    }}

}}}

bool searcher(int ks[],int tobesearched,int start){
if(start==0){
if(ks[start]==tobesearched){
return true;
}else{return false;}
}else{
if(ks[start]==tobesearched){
return true;
}else{if(ks[start]<tobesearched){
bool ress=false;
for(int sd=start-1;sd>=0;sd–){
if (ress==true){break;}
ress = ress || searcher(ks,tobesearched-ks[start],sd);
}
if(ress==false){
searcher(ks,tobesearched,start-1);
}else{return true;}
}else{searcher(ks,tobesearched,start-1);}
}
}}

void countsort(int k[],int maxim, int ksize){
char ks[maxim];
for (int x=0;x<maxim;x++){
ks[x]=‘a’;
}
for (int jf=0;jf<ksize;jf++){
ks[k[jf]-1]++;
}
int ksd=0;
for (int js=0;js<maxim;js++){
while(ks[js]!=‘a’){
k[ksd]=js+1;
ksd++;
ks[js]–;
}
}}

Sorting function works perfectly fine. I have used it in other problems too. The problem must be in other part.
This is my code…
Please give me some inputs on which it gives wrong answer.

Try the following testcase:
1
2 10
10
10

Your program gives ‘No’ but answer should be ‘Yes’

Thanks a lot… finally AC

welcome :slight_smile: