Pagini recente » Cod sursa (job #1915042) | Cod sursa (job #2183418) | Cod sursa (job #860619) | Cod sursa (job #2569979) | Cod sursa (job #46443)
Cod sursa(job #46443)
const lmax=13000;
var a,b:array[1..lmax]of word;
min,g,w,e,c,i,j:word;
f:text;
begin
assign(f,'energii.in');reset(f);
fillchar(a,sizeof(a),0);
readln(f,g,w);
readln(f,e,c);
a[e]:=c;
for i:=2 to g do begin
fillchar(b,sizeof(b),0);
readln(f,e,c);
for j:=1 to lmax do
if(a[j]<>0)and(j+e<=lmax) then
b[j+e]:=a[j]+c;
if(c<b[e])or(b[e]=0)then b[e]:=c;
for j:=1 to lmax do
if(b[j]=0)or(a[j]<>0)and(a[j]<b[j]) then b[j]:=a[j];
a:=b;
end;
min:=maxint;
for i:=w to lmax do
if (a[i]<>0)and(a[i]<min) then min:=a[i];
close(f);
assign(f,'energii.out');rewrite(f);
writeln(f,min);
close(f);
end.