poj 3627 Bookshelf

来源:互联网 发布:js中on和bind的区别 编辑:程序博客网 时间:2024/05/16 19:15
/*排序就行 */#define LOCAL#include<iostream>#define N 20001using namespace std;int cow[N];int cmp(const void *p,const void *q){return (*(int *)q-*(int *)p);}int main(){#ifdef LOCAL       freopen("input.txt","r",stdin);       freopen("output.txt","w",stdout);#endif            int n,i;    double b,sum;      //double消灭long long !     while(cin>>n>>b)    {             for(i=0;i<n;i++)                  cin>>cow[i];             qsort(cow,n,sizeof(int),cmp);             sum=0;             i=0;             while(sum<b)             {                 sum+=cow[i];                 i++;                           }                    cout<<i<<endl;                                  }    return 0;}

原创粉丝点击