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 WA?thx

Posted by xuning at 2007-04-19 13:18:36 on Problem 1042
#include <stdio.h>

int main( )
{
	int outnum=1,n,fit[26],fi[26],di[26],ti[26],i,j,k,out[26][26]={0,},fish=0,maxall=0,hour,minute5,t[26]={0,},timet,maxlake,max=0;
	while (1)
	{
		scanf( "%d" ,&n );
		if (n==0)
			return 0;
		scanf( "%d" ,&hour);
		minute5=hour*12;
		for (i=1;i<=n;i++)
			scanf("%d",&fi[i]);
		for (i=1;i<=n;i++)
			scanf("%d",&di[i]);
		for (i=1;i<=n-1;i++)
			scanf("%d",&ti[i]);
		for (i=2;i<=n;i++)
		{
			t[i]=t[i-1]+ti[i-1];
		}
		for (i=1;i<=n;i++)
		{
			timet=minute5-t[i];
			for (j=1;j<=n;j++)
				fit[j]=fi[j];
			for (j=1;j<=timet;j++)
			{
				maxlake=1;
				for (k=1;k<=i;k++)
					if (fit[k]>max)
					{
						max=fit[k];
						maxlake=k;
					}
				max=0;
				fish+=fit[maxlake];
				out[i][maxlake]++;
				fit[maxlake]-=di[maxlake];
				if (fit[maxlake]<0)
					fit[maxlake]=0;
			}
			if (fish>maxall)
			{
				maxall=fish;
				outnum=i;
			}
			fish=0;
		}
		for (i=1;i<=n-1;i++)
			printf("%d, ",out[outnum][i]*5);
		printf("%d",out[outnum][n]*5);
		printf("\nNumber of fish expected: %d\n\n",maxall);
		fish=0,maxall=0;
		for (i=0;i<=25;i++)
			t[i]=0;
		for (i=0;i<=n;i++)
			for (j=0;j<=n;j++)
				out[i][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