别看了,又是水题~~~~~
题意:好理解呀
#include<cstdio>
#include<algorithm>
#include<iostream>
#define ll long long
using namespace std;
ll map[20010];
int main()
{
int n;
ll b;
cin>>n>>b;
for(int i=0;i<n;i++)
cin>>map[i];
sort(map,map+n);
ll ans=0,tot=0;
for(int i=n-1;i>=0;i--)
{
tot+=map[i];
ans++;
if(tot>=b)
break;
}
if(tot<b)printf("-1\n");
else printf("%lld\n",ans);
return 0;
}