fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. int t;cin>>t;
  6. while(t--)
  7. {
  8. long long n,k;
  9. cin>>n>>k;
  10. int a,dp[100005]={0};
  11. for(int i=0;i<n;i++)
  12. {
  13. cin>>a;
  14. dp[a] =1;
  15. for(int j=k;j>=a;j--)
  16. {
  17. if(dp[j-a] == 1) dp[j] =1;
  18. }
  19. }
  20. if(dp[k] == 1) cout<<"YES"<<endl;
  21. else cout<<"NO"<<endl;
  22. }
  23. }
Success #stdin #stdout 0.01s 5544KB
stdin
3

6 33

1 4 20 3 10 5

7 7

1 4 0 0 3 10 5

2 0

1 4
stdout
YES
YES
NO