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

标准答案。。。

Posted by drownever at 2006-12-23 09:03:41 on Problem 2487
#include<iostream.h>
int main()
{
	int t;
	cin>>t;
    int tt=0;
	while(t--)
	{
		int array[1001],temp=0,people;
		long a;
		cin>>a>>people;
		while(people--)
		{
			cin>>array[temp++];
		}
		for(int i=0;i<temp;i++)
			for(int j=i;j<temp;j++)
			{
				if(array[i]<array[j])
				{
					int ss=array[j];
					array[j]=array[i];
					array[i]=ss;
				}
			}

		int result=1;
		long sum=0;
		people=temp;
		temp=0;
		while(1)
		{
			if(result>people)
			{
				cout<<"Scenario #"<<++tt<<":"<<endl<<"impossible"<<endl<<endl;	
				break;
			}
			sum=sum+array[temp++];

			if(sum>=a)
			{
				cout<<"Scenario #"<<++tt<<":"<<endl<<result<<endl<<endl;
			    break;
			}
			result++;
		}
	 
	}
	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