Pagini recente » Cod sursa (job #1445428) | Cod sursa (job #398704) | Cod sursa (job #548111) | Cod sursa (job #1290010) | Cod sursa (job #2628173)
from bisect import bisect_left, bisect_right
with open("date.in", "r") as f, open("date.out", "w") as g:
n, a, m = int(next(f)), list(int(i) for i in next(f).split()), int(next(f))
for i in range(m):
o, x = (int(i) for i in next(f).split())
if o == 0:
poz = bisect_right(a, x)
g.write(str(poz if poz and a[poz - 1] == x else -1))
elif o == 1:
g.write(str(bisect_right(a, x)))
else:
g.write(str(bisect_left(a, x) + 1))
g.write('\n')