http://172.21.2.10/JudgeOnline/problem.php?id=2237
复习了一下完全背包。
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
int n,m;int dp[11111];
int cos[111];int va[111];
while(scanf("%d%d",&n,&m)!=EOF)
{
memset(dp,0,sizeof(dp));
int i,j;
for(i=1;i<=n;i++)
{
scanf("%d%d",&cos[i],&va[i]);
}
for(i=1;i<=n;i++)
{
for(j=cos[i];j<=m;j++)
{
dp[j]=max(dp[j],dp[j-cos[i]]+va[i]);
}
}
printf("%d\n",dp[m]);
}
return 0;
}