Pagini recente » Rating Alexia (abc1213) | Cod sursa (job #2953414) | Cod sursa (job #3148746) | Cod sursa (job #2620740) | Cod sursa (job #1200017)
program energie;
type
tabel=array [0..10005] of longint;
var
t:tabel;
l,n,m,i,j,b,v,vv:longint;
f1,f2:text;
function max(a,b:longint):longint;
begin
if a>b then max:=a else
max:=b;
end;
begin
assign (f1,'energii.in');
assign (f2,'energii.out');
reset (f1);
rewrite (f2);
readln (f1,n);
readln (f1,m);
b:=100000000;
for i:=1 to n do begin
readln (f1,v,vv);
for j:=10002 downto vv do
begin
t[j]:=max(t[j],t[j-vv]+v);
end;
end;
for i:=10001 downto 1 do
if (t[i]>=m) and (b>i) then b:=i;
if b=100000000 then writeln(f2,-1) else
writeln (f2,b);
close (f1);
close (f2);
end.