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

Re:Notice~数据好弱啊~看书才知道贪心~唉~菜鸟一只~

Posted by like680623 at 2011-01-31 18:18:22 on Problem 1042
#include<iostream>
#include<algorithm>
using namespace std;

int main()
{
	int h, n, fi[26], time, ti[26], di[26], last[26], lasttime[26], value[26], maxf;
	while (cin>>n && n)
	{
		cin>>h;
		maxf = -2;
		for (int i = 1; i <= n; i++)
			cin>>fi[i];
		for (int i = 1; i <= n; i++)
			cin>>di[i];
		for (int i = 1; i <= n - 1; i++)
			cin>>ti[i];
		for (int i = 1; i <= n; i++)
		{
			memset(value, 0, sizeof(value));
			time = h * 60 / 5;
			int sumt = 0, sum = 0, num[26];
			for (int k = 1; k <= n; k++)
				num[k] = fi[k];
			for (int j = 1; j < i; j++)
				sumt += ti[j];
			time -= sumt;
			if (time <= 0)break;
			while (time > 0)
			{
				int temp, max = -1;
				for (int l = 1; l <= i; l++)
					if (max < num[l])
					{
						max = num[l];
						temp = l;
					}
				sum += num[temp];
				if (num[temp] >= di[temp])num[temp] -= di[temp];
				else num[temp] = 0;
				time -= 1;
				value[temp] += 1;
			}
			if (maxf < sum)
			{
				maxf = sum;
				for (int g = 1; g <= n; g++)
					last[g] = num[g];
				for (int g = 1; g <= n; g++)
					lasttime[g] = value[g] * 5;
			}
		}
		for (int g = 1; g <= n; g++)
		{
			if (g > 1)printf(", ");
			printf("%d", lasttime[g]);
		}
		cout<<endl;
		printf("Number of fish expected: %d\n\n", maxf);
	}
	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