题目: |
program jb2014_3
var
f:array[0..400,0..400] of integer;
n,mv,mw,v,w,x,i,j,k:integer;
function max(a,b:integer):integer;
begin
max:=a;
if max<b then max:=b;
end;
begin
readln(mv,mw);
readln(n);
for k:=1 to n do
begin
readln(v,w,x);
for i:=mv downto v do
for j:=mw downto w do
f[i,j]:=max(f[i,j],f[i-v,j-w]+x);
end;
writeln(f[mv,mw]);
end.
输入:
32 35
4
16 4 12
8 11 24
22 7 31
4 40 22
输出:55
|