标签:blog http io for 2014 amp log sp
#include <stdio.h>
int dp[12888];
int w[3408],d[3408];
int max(int x,int y) { return x>y?x:y; }
int main()
{
int n,m,i,j;
while(scanf("%d%d",&n,&m)!=EOF&&(n||m))
{
for(i=0;i<n;i++)
scanf("%d%d",&w[i],&d[i]);
for(i=0;i<=m;i++) dp[i]=0;
for(i=0;i<n;i++)
for(j=m;j>=w[i];j--)
dp[j]=max(dp[j],dp[j-w[i]]+d[i]);
printf("%d\n",dp[m]);
}
return 0;
}
标签:blog http io for 2014 amp log sp
原文地址:http://www.cnblogs.com/2014acm/p/3908478.html