| 记录编号 | 30979 | 评测结果 | AAAAAAAAAA | ||
|---|---|---|---|---|---|
| 题目名称 | 144.[USACO Dec07] 魅力手镯 | 最终得分 | 100 | ||
| 用户昵称 | 是否通过 | 通过 | |||
| 代码语言 | C++ | 运行时间 | 0.394 s | ||
| 提交时间 | 2011-11-01 11:24:09 | 内存使用 | 4.40 MiB | ||
#include <cstdio>
using namespace std;
int main(void)
{
freopen("charm.in","r",stdin);
freopen("charm.out","w",stdout);
int i,j,n,maxm,temp,wei[3402],val[3402],f[12881]={0};
scanf("%d %d\n",&n,&maxm);
for (i=0;i<n;i++)
scanf("%d %d\n",&wei[i],&val[i]);
for (i=0;i<n-1;i++)
for (j=maxm;j>=wei[i];j--)
{
temp=val[i]+f[j-wei[i]];
if (temp>f[j])
f[j]=temp;
}
temp=val[i]+f[maxm-wei[i]];
if (temp>f[maxm])
f[maxm]=temp;
printf("%d\n",f[maxm]);
fclose(stdin);
fclose(stdout);
return(0);
}