数据量比较小,dfs暴力水过
#include <bits/stdc++.h>
using namespace std;
int n,k;
int A[25];
bool correct = false;
void dfs(int cnt,int sum)
{
if(sum == k)
{
correct = true;
return;
}
if(correct) return;
if(cnt == n) return;
dfs(cnt+1,sum+A[cnt]);
dfs(cnt+1,sum);
}
int main()
{
ios::sync_with_stdio(false);
cin >> n >> k;
for(int i = 0; i < n; ++i)
cin >> A[i];
dfs(0,0);
if(correct) cout << "Yes" << endl;
else cout << "No" << endl;
return 0;
}