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
",ans);
    }
    return 0;
}
原文地址:https://www.cnblogs.com/zufezzt/p/5075340.html