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 liyuweihuo at 2015-09-18 19:53:36 on Problem 1042
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
using namespace std;
typedef struct
{
	int fi,di,ti;
}node;
node N[30];
int main()
{
	int n,h,i,j,t;
	int f[30],fi[30],num[30];
	while(~scanf("%d",&n),n)
	{
		scanf("%d",&h);
		h=h*60;
		for(i=1;i<=n;i++)
		scanf("%d",&N[i].fi);
		for(i=1;i<=n;i++)
		scanf("%d",&N[i].di);
		for(i=1;i<n;i++)
		scanf("%d",&N[i].ti);
		int time=0,fish=0,Fish=0;
		N[0].ti=0;
		memset(fi,0,sizeof(fi));
		for(i=1;i<=n;i++)
		{
			time+=N[i-1].ti;
			t=h-time*5;
			for(j=1;j<=i;j++)
			f[j]=N[j].fi,num[j]=0;
			fish=0;
			while(t>=5)
			{
				//printf("  %d\n",t);
				int Max=-1,z=-1;
				for(j=1;j<=i;j++)
				if(f[j]>Max)
				Max=f[j],z=j;
				t-=5;
				num[z]++;
				//printf("        %d\n",num[z]);
				fish+=f[z];
			    f[z]=0>f[z]-N[z].di?0:f[z]-N[z].di;
			}
			//printf("\n");
			//printf("     %d\n",fish);
			if(fish<Fish)
			continue;
			if(fish>Fish)
			{
				Fish=fish;
				for(j=1;j<=i;j++)
				fi[j]=num[j];
				//printf("            %d\n",num[j]);
				continue;
			}
			j=1;
			while(j<=n&&num[j]==fi[j])
			j++;
			if(num[j]>fi[j])
			{
			//	printf("564444444444444444444444\n");
			//	printf("%d   %d    %d\n",num[j],fi[j],j);
			for(j=1;j<=i;j++)
			fi[j]=num[j];
			//printf("%d   %d\n",num[j],fi[j]);
		    }
		}
		if(n==1)
		printf("%d\n",fi[1]*5);
		else
		{
		printf("%d,",fi[1]*5);
		for(j=2;j<n;j++)
		printf(" %d,",fi[j]*5);
		printf(" %d\n",fi[n]*5);
	    }
		printf("Number of fish expected: %d\n",Fish);
		printf("\n");
	}
	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