liye14 2011-07-31 02:50:00
点我顶贴
收藏
删除
var
n,t,i,j:longint;
q1,q2,w1,w2:array[1..30] of longint;
f:array[0..1080000] of longint;
begin
readln(n,t);
for i:=1 to n do
readln(w1[i],q1[i],w2[i],q2[i]);
for i:=1 to n do
begin
for j:= t downto q1[i] do
begin
if f[j-q1[i]]+w1[i]>f[j] then f[j]:=f[j-q1[i]]+w1[i];
if f[j-q2[i]]+w2[i]>f[j] then f[j]:=f[j-q2[i]]+w2[i];
end;
for j:=q1[i]-1 downto q2[i] do
if f[j-q2[i]]+w2[i]>f[j] then f[j]:=f[j-q2[i]]+w2[i];
end;
writeln(f[t]);
end.