首页 > 其他 > 详细

CodeForces 609A USB Flash Drives

时间:2015-12-25 13:16:13      阅读:273      评论:0      收藏:0      [点我收藏+]

水题

#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;
}

 

CodeForces 609A USB Flash Drives

原文:http://www.cnblogs.com/zufezzt/p/5075340.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!