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:牛人帮帮忙看看WA

Posted by 981950112 at 2010-02-08 19:47:04 on Problem 2487
In Reply To:牛人帮帮忙看看WA Posted by:xiaog1198 at 2010-02-07 19:16:39
> #include<stdio.h>
> int main()
> {
> 	int n,j,i,k,m,y,sum,a[1000],count,flag,max,z;
> 	scanf("%d\n",&n);
> 	for (i=1;i<=n;i++)
> 	{
> 		sum=0;count=0;flag=0;
> 		scanf ("%d %d\n",&z,&k);
> 		{
> 			for (j=0;j<=k-1;j++)
> 				scanf("%d",&a[j]);
> 			getchar();
> 			for (j=1;j<=k-1;j++)
> 			{
> 				for (m=0;m<=j-1;m++)
> 				{
> 					if (a[j]>a[m]) 
> 					{
> 						max=a[j];
> 						for (y=j-1;y>=m;y--)
> 							a[y+1]=a[y];
> 						a[m]=max;
> 					}
> 				}
> 			}
> 			while (sum<=z&&count<=k)
> 			{
> 				sum=sum+a[count++];
> 				if (sum>=z) {printf("Scenario #%d:\n",n);printf("%d\n",count);printf("\n");flag=1;break;}
> 			}
> 			if (flag==0) {printf("Scenario #%d:\n",n);printf("impossible\n");printf("\n");}
> 			for (j=0;j<=k-1;j++)
> 				a[j]=0;
> 		}
> 	}
> 	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