Pagini recente » Cod sursa (job #1803404) | Cod sursa (job #950336) | Cod sursa (job #95169) | Cod sursa (job #2245258) | Cod sursa (job #718870)
Cod sursa(job #718870)
var n,i,j,w,x,y,p,x1:integer;
f,g:text;
a:array[0..1001,0..5001]of longint;
begin
assign(f,'energii.in');reset(f);assign(g,'energii.out');rewrite(g);
read(f,n,w);
for i:=1 to n do
begin
read(f,x,y);
p:=1; x1:=x;
while x<=w do
begin
if i=1 then a[i,x]:=p*y else
if p*y<a[i-1,x] then a[i,x]:=p*y
else a[i,x]:=a[i-1,x];
x:=x+x1;
p:=p+1;
end;
end;
if a[n,w]<>0 then write(g,a[n,w]) else write(g,-1);
close(f);close(g);
end.