帮忙康康我怎么错的
#include<bits/stdc++.h>
using namespace std;
const int maxn=55;
const int maxm=5005;
int n,m,a[maxn],t,o,ans;
bool x[maxn],y[maxm];
void dp(){
memset(y,0,sizeof y);
y[0]=true;
ans=0;
t=0;
for(int i=0;i<n;i++){
if(x[i])continue;
for(int j=t;j>=0;j--){
if(y[j]&&!y[j+a[i]]){
y[j+a[i]]=true;
}
}
ans++;
t+=a[i];
}
o=max(ans,o);
}
void dfs(int cur,int now){
if(now>m)
return;
if(cur==n){
if(now==m)dp();
return;
}
dfs(cur+1,now);
x[cur]=true;
dfs(cur+1,now+1);
x[cur]=false;
}
int main(){
cin>>n>>m;
for(int i=0;i<n;i++){
scanf("%d",&a+i);
}
dfs(0,0);
cout<<o;
return 0;
}
求助dalao