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

why wrong?thanks

Posted by makelove at 2008-11-29 23:38:35 on Problem 3627
#include<iostream>
#include<algorithm>
using namespace std;
inline bool cmp(char a,char b) 
    { 
          return a>b; 
    } 
int a[20003];
int main()
{
	long int n,m,i,sum=0;
	cin>>n>>m;
	for(i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n,cmp);
	i=0;
	while(sum<m)
		sum+=a[i++];
	cout<<i<<endl;
	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