Pagini recente » Cod sursa (job #56013) | Cod sursa (job #105109) | Cod sursa (job #2111722) | Cod sursa (job #1913604) | Cod sursa (job #2628172)
from bisect import bisect_left, bisect_right
def main():
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))
bl, br = bisect_left, bisect_right
for i in range(m):
o, x = (int(i) for i in next(f).split())
if o == 0:
poz = br(a, x)
g.write(str(poz if poz and a[poz - 1] == x else -1))
elif o == 1:
g.write(str(br(a, x)))
else:
g.write(str(bl(a, x) + 1))
g.write('\n')
return 0
if __name__ == "__main__":
main()