编译没问题,单纯不输出,帮忙看一下问题所在|验证码祭之
#include<bits/stdc++.h>
using namespace std;
int main(){
int ths,bgsp,bagnow=0;
cin>>ths>>bgsp;
int allths=0;
int a[ths];
queue <int> bag;
for(int i=0;i<ths;i++)cin>>a[i];
sort(a,a+(ths-1));
for(int j=0;j<ths;j++){
if(bagnow+a[j]<=bgsp){
allths++;
bagnow+=a[j];
bag.push(a[j]);
}else{
cout<<allths<<endl;
while(!bag.empty()){
cout<<bag.front()<<" ";
bag.pop();
}
}
}
return 0;
}