# Help me in solving A1 problem

### My issue

plz provide me DP sol of this

### My code

``````#include <bits/stdc++.h>
using namespace std;

// use dp
bool funsum(int ind,int n,int m,vector<int>& v){
if(m==0)return true;

if(m-v[ind]==0){
return true;
}

if(m<0 || ind>=n) return false;

return  funsum(ind+1,n,m-v[ind],v)|| funsum(ind+1,n,m,v);
}
int main() {
// your code goes here
int t;
cin>>t;
while(t--){
int n,m;
cin>>n>>m;
vector<int>v(n);
for(int i=0;i<n;i++){
cin>>v[i];
}
if(funsum(0,n,m,v)==1)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}
return 0;
}

``````

Problem Link: A1 Problem - CodeChef

@deepakjdh31
Here u go plzz refer my dp solution .

``````#include <bits/stdc++.h>
using namespace std;
int dp[21][20001];
bool check(vector<int>& a,int s,int i)
{
if(i==a.size())
{
if(s==0)
return 1;
return 0;
}
if(dp[i][s]!=-1)
return dp[i][s];
bool take=false;
if(a[i]<=s)
{
take=check(a,s-a[i],i+1);
}
bool nottake=check(a,s,i+1);
return dp[i][s]=take|nottake;
}
int main() {
// your code goes here
int t;
cin>>t;
while(t--)
{
int n,s;
cin>>n>>s;
vector<int> a(n);
for(int i=0;i<n;i++)
{
cin>>a[i];
}
memset(dp,-1,sizeof(dp));
if(check(a,s,0))
cout<<"Yes";
else
cout<<"No";
cout<<endl;
}
return 0;
}
``````