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

哇靠我投降了测试了一堆包括全零的都OK就是WA到死阿。。我无耻的COPY别人的数据AC。。这发一帖贴上自己的源码好了。。。

Posted by zonelight at 2009-02-18 02:41:30 on Problem 1042
提醒一下一句话 “If there is still a tie, choose the one that spends as long as possible at lake 2”
不然的话最开始的会是25,5。。。麻痹这题目这么设计真是蛋疼。。。。。。。。。

#include <iostream>
using namespace std;
int tmpfish = 0;
int FFF[25] = {0};
void solutionsmall(int HH,int ii,int FF[],int DD[],int timet[])
{
	int i,j;
	int maxnum = 0;
	if(ii == 0)
	{
		for(;HH > 0 && FF[0] > DD[0];HH--)
		{
			tmpfish = tmpfish + FF[0];
			FF[0] = FF[0] - DD[0];
			timet[0] = timet[0] + 5;
			
		}
		return;
	}
	for(i = 1;i < ii + 1;i++)
	{
		if(FF[i] > FF[maxnum])
		{
			maxnum = i;		       
		}
	}
	tmpfish = tmpfish + FF[maxnum];
	FF[maxnum] = FF[maxnum] - DD[maxnum];
	HH = HH - 1;
	timet[maxnum] = timet[maxnum] + 5;
	if(HH > 0)
	{
		if(FF[maxnum] >= 0)
		{
			solutionsmall(HH,ii,FF,DD,timet);
		}
		else
		{
			timet[maxnum - 1] = timet[maxnum - 1] + HH * 5;
			return;
		}
	}	
	else
	{
		return;
	}
	
}

void solution(int N,int H,int F[],int D[],int T[] )
{
	int i,j;
	H = H * 12;
	int tmph = H;
	int time[25] = {0};
	int allfish = 0;
	int first[25] = {0};
	int k = 0;
	int recovery[25][25] = {0};
	int nums;
	for(i = 1;i <= N;i++)
	{
		for(j = 0;j < i - 1;j++)
		{
			if(i - 1 > 0)
			{
				H = H - T[j];
			}
		}
		solutionsmall(H,i - 1,F,D,time);
		
		
		first[k++] = time[0];
		for(j = 0;j < i;j++)
		{
			recovery[k - 1][j] = time[j];
		}
		if(tmpfish > allfish)
		{
			allfish = tmpfish;		
			nums = i;
		}
		else if(tmpfish == allfish)
		{
			if(first[k - 1] > first[k])
			{
				for(j = 0;j < i;j++)
				{
					time[j] = recovery[k - 1][j];
				}
				
			}
			nums--;
		}
		H = tmph;
		tmpfish = 0;
		for(j = 0;j < i;j++)
		{
			F[j] = FFF[j];			
		}
		if(i != N)
		{
			for(j = 0;j < i;j++)
			{
				time[j] = 0;
			}
		}
	}
	for(i = 0;i < nums;i++)
	{
		if(i!= nums - 1)
		{
			cout<<time[i]<<",";
		}
		else
		{
			cout<<time[i]<<endl;
		}
	}
	cout<<"Number of fish expected:"<<allfish<<endl<<endl;

}



int main(void)
{
	int n,h;
	int i,j;
	int f[25] = {0},d[25] = {0},t[24] = {0};
	while(cin>>n)
	{
		if(n <= 0)
		{
			return 0;
		}
		else
		{
			cin>>h;
			for(i = 0;i < n;i++)
			{
				cin>>f[i];
				FFF[i] = f[i];
			}
			for(i = 0;i < n;i++)
			{
				cin>>d[i];
			}
			for(i = 0;i < n - 1;i++)
			{
				cin>>t[i];
			}
			solution(n,h,f,d,t);
		}
	}

			
			
	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