Pagini recente » Cod sursa (job #1272669) | Cod sursa (job #456464) | Cod sursa (job #597445) | Cod sursa (job #1878166) | Cod sursa (job #2004030)
var g,n,i,j,x,y,s:longint;
t:array[0..10000] of longint;
o:array[1..5000] of record m:longint;
v:longint;
end;
{function pune(g,y,s:longint):longint;
var i,j,k:longint;
begin
if g<=0 then pune:=0 else
begin
if o[s].m<=g then j:=
end;
end; }
begin
assign(input,'rucsac.in');
reset(input);
readln(n,g);
for x:=1 to n do
readln(o[x].m,o[x].v);
close(input);
{s:=pune(g,y,1); }
for i:=1 to n do
for j:=g downto 1 do
begin
if j-o[i].m>=0 then y:=t[j-o[i].m]+o[i].v else y:=0;
if y>t[j] then t[j]:=y;
end;
assign(output,'rucsac.out');
rewrite(output);
write(t[g]);
close(output);
end.