#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define N 1001
int ans[N];
int max(int a,int b)
{
if(a>b)
    return a;
    return b; 
}
int main()
{
	int n,v,c,w;
	int max(int,int);
	while(scanf("%d%d",&n,&v),n||v)
	{
		memset(ans,0,sizeof(ans));
		for(int i=1;i<=n;i++)
		{
			scanf("%d%d",&c,&w);
			for(int j=v;j>=c;j--)
				ans[j]=max(ans[j],ans[j-c]+w);
		}
		printf("%d\n",ans[v]);
	}
	system("pause");
	return 0;
}

  

相关文章:

  • 2021-09-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-01-18
  • 2022-02-26
  • 2021-12-16
  • 2021-10-31
  • 2021-12-13
相关资源
相似解决方案