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

自己写的代码就是WA。。~~~~(>_<)~~~~ 。没理由啊

Posted by rainbowwing at 2010-04-14 23:26:12 on Problem 1042 and last updated at 2010-04-15 19:54:01
#include<stdio.h>

struct Num
{
	int f;
	int d;
}lakes[28];

int f[28],visit[28],result[28],dist[28];

void main()
{
	int i,j,n,k,h,t,t0,sum,max,fish,temp;

	dist[0]=0;

	while(1)
	{
		scanf("%d",&n);

		if(n==0)break;

		scanf("%d",&h);

		for(i=1;i<=n;i++)
			scanf("%d",&lakes[i].f);
		for(i=1;i<=n;i++)
			scanf("%d",&lakes[i].d);

		for(i=1;i<n;i++)
		{
			scanf("%d",&dist[i]);
			dist[i]=dist[i]+dist[i-1];
		}


		t0=h*12;
		sum=0;

		for(i=1;i<=n;i++)
			result[i]=0;

		for(i=1;i<=n;i++)
		{
		
			fish=0;

			for(j=1;j<=i;j++)
			{
				f[j]=lakes[j].f;
				visit[j]=0;
			}
			t=t0-dist[i-1];

			if(t<=0)break;
			while(t)
			{
				max=0;
				temp=1;
				for(j=1;j<=i;j++)
					if(f[j]>max)
					{
						max=f[j];
						temp=j;
					}

                    if(max==0)break;
				
					visit[temp]++;
					fish=fish+f[temp];
					f[temp]=f[temp]-lakes[temp].d;
					if(f[temp]<0) 
						f[temp]=0;

					t--;
			}

			visit[1]=visit[1]+t;

			if(fish>sum)
			{
				sum=fish;
				for(j=1;j<=i;j++)
					result[j]=visit[j];
			}
			else if(sum==fish)
			{
				for(j=1;j<=i;j++)
					if(result[j]<visit[j])
						break;
					if(j<=i)
						for(j=1;j<=i;j++)
                                 result[j]=visit[j];
			}

		}
	
	  printf("%d",result[1]*5);     
	  for(i=2;i<=n;i++)       
		  printf(", %d",result[i]*5);   
	  printf("\nNumber of fish expected: ");     
	  printf("%d\n",sum);      
	  printf("\n");  
	}
}

//这么可爱的代码会错在那里呢?呜呜~~~~(>_<)~~~~ 

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