Pagini recente » Cod sursa (job #2736896) | Cod sursa (job #1621643) | Cod sursa (job #1898667) | Cod sursa (job #2294158) | Cod sursa (job #718868)
Cod sursa(job #718868)
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;
write(g,a[n,w]);
close(f);close(g);
end.