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 decster at 2004-10-19 18:37:42 on Problem 1042
#include <iostream.h>
#include <string.h>

	int num=0;
	int h;
	int f[25];
	int d[25];
	int t[25];
	int currentstaytime[25];
	int maxnum=1;
	int maxfish=0;
	int staytime[25];

void tomax(int testnum)
{
	if(testnum>maxfish)
	{
		maxnum=num;
		maxfish=testnum;
		for(int i=0;i<num;i++) staytime[i]=currentstaytime[i];
	}
}
int findpartmax(int testnum)
{
	int i,j;
	int maxindex;
	int maxfish;
	int totalfish=0;
	int totaltime=h*12;
	int fishtemp[25];
	memset(currentstaytime,0,50);
	for(i=0;i<=testnum;i++) fishtemp[i]=f[i];
	for(i=0;i<testnum;i++) 
		totaltime-=t[i];
	for(i=0;i<totaltime;i++)
	{
		maxfish=fishtemp[0];
		maxindex=0;
		for(j=1;j<=testnum;j++)
		{
			if(maxfish<fishtemp[j])
			{
				maxindex=j;
				maxfish=fishtemp[j];
			}
		}
		currentstaytime[maxindex]+=5;
		totalfish+=maxfish;
		fishtemp[maxindex]-=d[maxindex];
		if(fishtemp[maxindex]<=0) fishtemp[maxindex]=0;
	}
	return totalfish;
}
void main()
{

	int i;
	cin>>num;
	while(num!=0)
	{
		cin>>h;
		for(i=0;i<num;i++) cin>>f[i];
		for(i=0;i<num;i++) cin>>d[i];
		for(i=0;i<num-1;i++) cin>>t[i];
		
		for(i=0;i<num;i++)
		{
			tomax(findpartmax(i));
		}
		for(i=0;i<maxnum-1;i++) cout<<staytime[i]<<", ";
		cout<<staytime[maxnum-1]<<endl;
		cout<<"Number of fish expected: "<<maxfish<<endl;
		cin>>num;
		if(num!=0) cout<<endl;
	}
}

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