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