Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Please help look for my bugs! I tried a few times but failed. Thx a lot!

Posted by jackoblee at 2008-08-28 17:44:18 on Problem 3627
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator