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:dp问题!附代码!

Posted by 20142430108 at 2016-06-06 12:27:09 on Problem 3624
In Reply To:dp问题!附代码! Posted by:chenxuan123456789 at 2012-07-31 11:02:56
> #include <stdio.h>
> #include <string.h>
> #define M 14000
> int dp[M];
> 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]);
> 	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