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

那位大牛帮我看看3211的程序。万分感激

Posted by pphechuan at 2007-04-02 20:20:28
#include<iostream>
#include<string>

using namespace std;

const maxn=30001;
int main()
{
	int F[11][101];
	char S[11][11];
	char t[11];
	int temp;
	int n,m;
	cin>>n>>m;
	for (int i=1;i<=n;i++)
	{
		cin>>S[i];
	}
	for (i=1;i<=n;i++)
		for (int j=0;j<=m;j++)
		{
			F[i][j]=0;
		}
	for (i=1;i<=m;i++)
	{
		cin>>temp>>t;
		for (int j=1;j<=n;j++)
		{
			if (0==strcmp(t,S[j]))
			{
				F[j][0]++;
				F[j][F[j][0]]=temp;
			}
		}
	}
	int answer=0;
	for (int u=1;u<=n;u++)
	{
		bool V[101][maxn];
		int temp2;
		temp=0;
		for (int i=1;i<=F[u][0];i++)
		{
			temp+=F[u][i];
		}
		temp2=temp / 2;

		for (i=0;i<=F[u][0];i++)
		{
			for (int j=1;j<=temp2;j++)
			{
				V[i][j]=false;
			}
			V[i][0]=true;
		}
		for (i=1;i<=F[u][0];i++)
			for (int j=1;j<=temp2;j++)
			{
				V[i][j]=V[i-1][j];
				if (j>=F[u][i])
				{
					if (V[i-1][j-F[u][i]])
						V[i][j]=true;
				}
			}
		for (i=temp2;i>=0;i--)
		{
			if (V[F[u][0]][i])
			{
				answer+=temp-i;
				break;
			}

		}
	}


	cout<<answer<<endl;
	return 1;
}

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