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

1A,纪念100题。

Posted by 1001030088 at 2011-10-08 14:01:55 on Problem 3624
#include<stdio.h>
#include<string.h>
#define MAXN 12900
int dp[MAXN];
int main()
{
	int n,m,v,w;
	memset(dp,0,sizeof(dp));
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&w,&v);
		for(int j=m;j>=w;j--)
		{
			int temp=dp[j-w]+v;
			if(temp>dp[j])
		 		dp[j]=temp;
		}	
	}
	printf("%d\n",dp[m]);
}

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