Pagini recente » Cod sursa (job #2534744) | Cod sursa (job #2220448) | Cod sursa (job #4386) | Cod sursa (job #3253936) | Cod sursa (job #962677)
Cod sursa(job #962677)
uses crt;
type vector=array[1..20000]of longint;
var f,h:text;
G,W,i,p,y:longint;
E,C:vector;
procedure cmin(i,j:longint;var p:longint);
var p1:longint;
begin
if i=j then
begin
if E[i]>=W then p:=C[i]
else p:=-1;
end;
if i<j then
begin
if E[i]>=W then p:=C[i]
else p:=-1;
cmin(i+1,j,p1);
if (p1=-1)and(p=-1) then p:=-1;
if (p1<>-1)and(p=-1) then p:=p1;
if (p1<>-1)and(p<>-1) then if p1<=p then p:=p1;
end;
end;
begin
clrscr;
assign(f,'energii.in');
reset(f);
read(f,G);
read(f,W);
for i:=1 to G do
begin
read(f,E[i]);
read(f,C[i]);
end;
close(f);
cmin(1,G,p);
assign(h,'energii.out');
rewrite(h);
write(h,p);
close(h);
end.