题目:
贪心:
#include<bits/stdc++.h>
using namespace std;
#define M 100005
int a[M];
bool cmp(int n1,int n2)
{
return n1>n2;
}
int main()
{
int N,B;
cin>>N>>B;
for(int i=1;i<=N;i++)
{
cin>>a[i];
}
sort(a+1,a+N+1,cmp);
int sum=0;
int count=0;
for(int i=0;sum<B;i++)
{
sum+=a[i+1];
count++;
}
cout<<count<<endl;
}