| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
Please help look for my bugs! I tried a few times but failed. Thx a lot!#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
long int n,b,i,j,count,u;
bool a=false;
int cow[20005];
cin>>n>>b;
for (i=1;i<=n;i++)
cin>>cow[i];
sort(cow,cow+n);
i=1;
j=n;
count=0;
while (a==false&&i<=n)
{
count+=cow[j-i+1];
if (count>=b)
{
a=true;
cout<<i<<endl;
}
++i;
}
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator