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

With the transition equation of others, I still get WA. It really sucks...

Posted by yogafrank at 2008-10-24 00:09:14 on Problem 2626
In Reply To:为什么老是wa呢 Posted by:leilei at 2005-10-03 22:14:39
#include <iostream>
using namespace std;

class Person
{
public:
	int b, w;
};

Person p[1000];
int n, dp[1000][16][16];

int max( int a, int b )
{
	return a < b ? b : a;
}

int main()
{
	int s, t, i = 0;

//	freopen( "2626.txt", "r", stdin );
	while( scanf( "%d%d", &p[i].w, &p[i].b ) != -1 )
		i++;
	
	n = i;
	memset( dp, 0, sizeof( dp ) );
	dp[0][1][0] = p[0].w;
	dp[0][0][1] = p[0].b;

	for( i = 1; i < n; i++ )
		for( s = 1; s <= 15; s++ )
			for( t = 1; t <= 15; t++ )
			{
				if( s + t <= i + 1 )
					dp[i][s][t] = max( dp[i - 1][s][t], max( dp[i - 1][s - 1][t] + p[i].w, dp[i - 1][s][t - 1] + p[i].b ) );
			}
	printf( "%d\n", dp[n - 1][15][15] );

	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