Pagini recente » Cod sursa (job #222982) | Cod sursa (job #343538) | Cod sursa (job #1838035) | Cod sursa (job #2475685) | Cod sursa (job #689451)
Cod sursa(job #689451)
var v,b,c:array[1..10000]of integer;
f,g:text;
i,j,n,m,k:integer;
begin
assign(f,'cautbin.in');reset(f);
assign(g,'cautbin.out');rewrite(g);
readln(f,n);
for i:=1 to n do
read(f,v[i]);
readln(f,m);
for i:=1 to m do
begin
readln(f,b[i],c[i]);
if b[i]=0 then begin
for j:=n downto 1 do
if (v[j]=c[i]) then begin k:=1; writeln(g,j);break;end;
if k=0 then writeln(g,-1);
end;
if b[i]=1 then begin
for j:=n downto 1 do
if v[j]<=c[i] then begin writeln(g,j);break;end;end;
if b[i]=2 then begin
for j:=1 to n do
if v[j]>=c[i] then begin
writeln(g,j);
break;
end;
end;
end;
close(g);
close(f);
end.