CodeForces 609A USB Flash Drives

水题

#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;

const int maxn=100+10;
int a[maxn];

int main()
{
    int n,m;
    while(~scanf("%d%d",&n,&m))
    {
        for(int i=1; i<=n; i++) scanf("%d",&a[i]);
        sort(a+1,a+1+n);
        int ans=0;
        for(int i=n; i>=1; i--)
        {
            ans++;
            m=m-a[i];
            if(m<=0) break;
        }
        printf("%d\n",ans);
    }
    return 0;
}

 

posted @ 2015-12-25 11:16  Fighting_Heart  阅读(197)  评论(0编辑  收藏  举报