提交时间:2023-10-10 13:50:59
运行 ID: 106253
#include<bits/stdc++.h> using namespace std; int n,m,a[101]; void dfs(int r,int k,int s) { if(r==s) { cout<<"yes"; exit(0); } for(int i=k;i<=n;i++) if(r+a[i]<=m) dfs(r+a[i],k+1,m-r-a[i]); } int main() { cin>>n>>m; for(int i=1;i<=n;i++) cin>>a[i]; dfs(0,1,m); cout<<"no"; return 0; }