讨论 / 题解!
tchwr 2015-10-25 22:10:03
点我顶贴 收藏 删除
var c:array[1..30001]of longint;

w:array[1..30001]of integer;

V,max,i,j:longint;

n,open,closed:integer;

f:array[0..30001]of longint;

begin

read(V,n);

for i:=1 to n do read(c[i],w[i]);

fillchar(f,sizeof(f),0);

for i:=1 to n do

for j:=V downto c[i] do if f[j-c[i]]+w[i]>f[j] then f[j]:=f[j-c[i]]+w[i];

max:=0;

for i:=1 to V do if max<f[i] then max:=f[i];

write(max);

end.

#1 tchwr@2015-10-25 23:09:19
回复 删除
请自动把open和closed屏蔽掉。

#2 yeyutao@2015-10-26 02:12:17
回复 删除
挂机
#3 格斗家677i@2016-02-06 03:58:46
回复 删除
01背包
查看更多回复
提交回复