题解:本题主要考查背包方案数。
代码如下:
#include <iostream>
#include <cstdio>
using namespace std;
#define maxn 3403
#define maxm 12881
int m,n,w[maxn],c[maxn],f[maxm];
int main()
{
scanf("%d%d",&n,&m);
for (int i=1;i<=n;++i)
scanf("%d%d",&w[i],&c[i]);
for (int i=1;i<=n;++i)
for (int v=m;v>=w[i];--v)
if (f[v-w[i]] + c[i] > f[v])
f[v] = f[v-w[i]]+c[i];
printf("%d",f[m]);
return 0;
}