Pagini recente » Cod sursa (job #1271419) | Cod sursa (job #1452804) | Cod sursa (job #2150516) | Cod sursa (job #2959464) | Cod sursa (job #114656)
Cod sursa(job #114656)
type gener=record
e,c:longint;
end;
var f1,f2:text;
i,j,g,w:longint;
a:array[1..1010] of gener;
aux:gener;
v,vf:array[0..100000] of longint;
begin
assign(f1,'energii.in');
reset(f1);
assign(f2,'energii.out');
rewrite(f2);
read(f1,g,w);
for i:=1 to g do
read(f1,a[i].e,a[i].c);
for i:=1 to g-1 do
for j:=i+1 to g do
if a[i].c<a[j].c then
begin
aux:=a[i];
a[i]:=a[j];
a[j]:=aux;
end;
for i:=1 to w do
v[i]:=maxlongint;
vf:=v;
for i:=1 to g do
for j:=0 to w do
begin
if vf[j]<>maxlongint then
if vf[j]+a[i].c<vf[j+a[i].e] then
v[j+a[i].e]:=vf[j]+a[i].c;
vf[j]:=v[j];
end;
writeln(f2,v[w]);
close(f1);
close(f2);
end.