Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.024 s | 3 KBi |
#2 |
Correcto
|
0.026 s | 3 KBi |
#3 |
Correcto
|
0.031 s | 3 KBi |
#4 |
Correcto
|
0.027 s | 3 KBi |
#5 |
Correcto
|
0.036 s | 3 KBi |
#6 |
Correcto
|
0.043 s | 3 KBi |
#7 |
Correcto
|
0.027 s | 7 KBi |
#8 |
Correcto
|
0.032 s | 3 KBi |
#9 |
Correcto
|
0.037 s | 3 KBi |
#10 |
Correcto
|
0.044 s | 3 KBi |
#11 |
Correcto
|
0.03 s | 5 KBi |
#12 |
Correcto
|
0.471 s | 9 KBi |
#13 |
Correcto
|
0.843 s | 5 KBi |
#14 |
Correcto
|
1.093 s | 15 KBi |
#15 |
Correcto
|
0.965 s | 15 KBi |
#16 |
Correcto
|
0.841 s | 14 KBi |
#17 |
Correcto
|
0.459 s | 14 KBi |
def findIndex(arr, num, l, m, r, mem={}): if num in mem: return mem[num] if l >= r: mem[num] = m + 1 return m + 1 if arr[m] <= num: l = m+1 return findIndex(arr, num, l, (l + r) // 2, r, mem) else: r = m return findIndex(arr, num, l, (l + r) // 2, r, mem) N = int(input()) arr = list(map(lambda x: int(x), input().split(' '))) c = int(input()) for i in range(c): consulta = int(input()) print(findIndex(arr, consulta, 0, (len(arr)-1)//2, len(arr))-1)