Pagini recente » Cod sursa (job #933753) | Cod sursa (job #325752) | Cod sursa (job #2444341) | Cod sursa (job #2134027) | Cod sursa (job #137295)
Cod sursa(job #137295)
program garaj;
var nr,i,j,aux,n,m,c,t,min:longint;
s,d:array[1..10000] of integer;
procedure citire;
var f:text;
begin
assign(f,'garaj.in');
reset(f);
read(f,n,m);
for i:=1 to n do
begin
readln(f);
read(f,s[i],d[i]);
if d[i]<min then
min:=d[i];
end;
for i:=1 to n-1 do
for j:=i+1 to n do
if (s[i]/d[i])<(s[j]/d[j]) then
begin
aux:=s[i];
s[i]:=s[j];
s[j]:=aux;
aux:=d[i];
d[i]:=d[j];
d[j]:=aux;
end;
close(f);
end;
procedure afisare;
var g:text;
begin
assign(g,'garaj.out');
rewrite(G);
write(g,t,' ',c);
closE(g);
end;
begin
min:=maxlongint;
citire;
for t:=min*2 to maxlongint do
begin
nr:=0;
for i:=1 to n do
if nr>=m then
begin
i:=i-1;
break;
end else
nr:=nr+(t div (2*d[i]))*s[i];
if nr>=m then
begin
c:=i;
break;
end;
end;
afisare;
end.