Pagini recente » Cod sursa (job #923194) | Cod sursa (job #2627122) | Cod sursa (job #2539782) | Cod sursa (job #2739750) | Cod sursa (job #265443)
Cod sursa(job #265443)
var i,g,w,a,b,c,min:integer;
f,e:text; nul,ok:boolean; v,j:array [1..100] of integer;
BEGIN
assign(f,'energii.in');reset(f);assign(e,'energii.out');rewrite(e);
readln(f,g);readln(f,w);ok:=false;nul:=false; c:=10001;
IF (G>1) and (G<1001) and (W>1) and (W<5001) THEN
BEGIN
for i:=1 to g do
begin
readln(f,a,b);v[i]:=a;j[i]:=b;
end;
for i:=1 to g do
if (v[i]>=10001) or (j[i]>=10001) or (v[i]<1) or (j[i]<1) then
begin
nul:=true;ok:=true;
end;
if nul=false then
begin
for i:=1 to g do
if v[i]>=w then ok:=true;
if ok=true then
for i:=1 to g do
BEGIN
a:=v[i];b:=j[i];
if (a>=w) and (b<c) then
begin
c:=b;min:=a;
end;
END;
if ok=false then write(e,-1);
if ok=true then write(e,c);
close(f);close(e);
END;
END;
END.