//AC (2ms, 720KB)
int i,j,n,v[101],w[10001],c[10001],z,xx,sav;
main()
{
while(scanf("%d",&n)!=EOF){
for(xx=0;xx
{
scanf("%d %d",&w[xx],&c[xx]);
}
for(i=1;i<=100;i++) v[i]=0;
for(i=0;i
{
for(j=100;j-w[i]>=0;j--)
{
if(v[j-w[i]]+c[i]>v[j])
{
v[j]=v[j-w[i]]+c[i];
}
}
}
for(z=sav=0;z<101;z++)
{
if(v[z]>sav) sav=v[z];
}
printf("%d\n",sav);
}
}
main()
{
while(scanf("%d",&n)!=EOF){
for(xx=0;xx
{
scanf("%d %d",&w[xx],&c[xx]);
}
for(i=1;i<=100;i++) v[i]=0;
for(i=0;i
{
for(j=100;j-w[i]>=0;j--)
{
if(v[j-w[i]]+c[i]>v[j])
{
v[j]=v[j-w[i]]+c[i];
}
}
}
for(z=sav=0;z<101;z++)
{
if(v[z]>sav) sav=v[z];
}
printf("%d\n",sav);
}
}
沒有留言:
張貼留言