Pagini recente » Cod sursa (job #2711009) | Cod sursa (job #220623) | Cod sursa (job #1147651) | Cod sursa (job #1908026) | Cod sursa (job #962998)
Cod sursa(job #962998)
program p1;
var a:array[0..100000] of longint;
f,g:text;
i,n,m,u,x,k:longint;
begin
assign(f,'cautbin.in');reset(F);
assign(g,'cautbin.out');rewrite(G);
readln(f,n);
for i:=1to n do read(F,a[i]);
readln(F);
readln(f,m);
k:=1;
while k<=m do begin
readln(f,u,x);
if u=0 then
for i:=n downto 1 do
if (a[i]=x) or (a[i]=-1) then begin
writeln(g,i);
break;
end;
if u=1 then for i:=n downto 1 do
if (a[i]<=x) then begin
writeln(g,i);
break;
end;
if u=2 then for i:=1 to n do
if a[i]>=x then begin
writeln(g,i);
break;
end;
inc(k);
end;
close(F);
close(G);
end.