Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool dp(int sum,int n){
- int uk=0;
- for(int i=0;i<=sum;++i)
- vis[i]=false;
- vis[0]=true;
- for(int i=0;i<n;++i){
- for(int j=num[i]+uk;j>=num[i];j--){
- if(j<=sum&&vis[j-num[i]]==true){
- if(vis[j]==true){
- return true;
- }
- vis[j]=true;
- }
- }
- uk+=num[i];
- }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement