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 maomao19850615 at 2007-11-23 17:17:21 on Problem 1042
#include <iostream>
using namespace std;

main()
{
	int n,h,f[30],d[30],t[30],island,sum,sum2[30],k,times;
	int u,j,i,q,max,count[30][30],c,f2[30];
	while(scanf("%d",&n)&&n!=0)
	{
		cin>>h;
		for(i=0;i<n;i++)
			cin>>f[i];
		for(i=0;i<n;i++)
			cin>>d[i];
		t[0]=0;
		for(i=1;i<n;i++)
			cin>>t[i];
		for(i=0;i<30;i++)
		{
			for(j=0;j<30;j++)
				count[i][j]=0;
		}
		times=h*12;	
		for(island=1;island<=n;island++)					//每种岛数的情况!
		{
			for(u=0;u<island;u++)
				f2[u]=f[u];
			sum2[island]=0;
			times=times-t[island-1];
			if(times<0)
				break;
			for(j=0;j<times;j++)						//每次既情况,times为次数
			{
				max=f2[0];
				c=0;
				for(q=0;q<island;q++)					//选定的岛作比较
				{				
					if(f2[q]>max)
					{
						max=f2[q];
						c=q;
					}	
				}
				sum2[island]=sum2[island]+f2[c];
				count[island][c]++;
				if(f2[c]-d[c]>=0)
					f2[c]=f2[c]-d[c];
				else
					f2[c]=0;
			}
		}
			
			max=sum2[1];
			k=1;
			for(i=1;i<=n;i++)
			{
				if(sum2[i]>max)
				{
					max=sum2[i];
					k=i;
				}
			}
			cout << 5*count[k][0];
			for(i=1; i<n; i++)
				cout << ", " << 5*count[k][i];
			cout << endl;
			cout << "Number of fish expected: " << max << endl << 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