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

Re:RunError Why?

Posted by lithum at 2009-08-12 17:18:52 on Problem 2487
In Reply To:RunError Why? Posted by:alzhu at 2008-12-15 19:07:02
> #include <stdio.h>
> #include <iostream>
> #include <string>
> #include <cmath>
> #include <algorithm> 
> using namespace std;
> 
> 
> int main()
> {
> 	int a,b,d,e,f,k,impossible;
> 	scanf("%d",&a);
> 	for(int i=1;a--;i++)
> 	{
> 		scanf("%d%d",&b,&f);
> 		int *c=new int[b];
> 		for(int j=0;j<f;j++)
> 		{
> 			scanf("%d",&c[j]);
> 		}
> 		sort(&c[0],&c[f]);
> 		d=0;
> 		impossible=0;
> 		for(k=f-1,e=0;d<b;k--,e++)
> 		{
> 			if(k<0)
> 			{
> 				impossible=1;
>                               break;//这里要退出循环!
> 			}
> 			d+=c[k];
> 		}
> 		printf("Scenario #%d:\n",i);
> 		if(!impossible)
> 			printf("%d\n\n",e);
> 		else
> 			printf("impossible\n\n");
> 		delete [] c;
> 	}
> 	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