Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.015 s | 3 KBi |
#2 |
Correcto
|
0.014 s | 3 KBi |
#3 |
Correcto
|
0.015 s | 3 KBi |
#4 |
Correcto
|
0.016 s | 3 KBi |
#5 |
Correcto
|
0.014 s | 3 KBi |
#6 |
Correcto
|
0.015 s | 3 KBi |
#7 |
Correcto
|
0.015 s | 3 KBi |
#8 |
Correcto
|
0.016 s | 3 KBi |
#9 |
Correcto
|
0.016 s | 3 KBi |
#10 |
Correcto
|
0.015 s | 3 KBi |
#11 |
Correcto
|
0.015 s | 3 KBi |
#12 |
Correcto
|
0.402 s | 9 KBi |
#13 |
Correcto
|
0.367 s | 6 KBi |
#14 |
Correcto
|
0.444 s | 14 KBi |
#15 |
Correcto
|
0.41 s | 14 KBi |
#16 |
Correcto
|
0.377 s | 14 KBi |
#17 |
Correcto
|
0.388 s | 14 KBi |
def binary_search(arr, low, high, x): if high >= low: mid = (high + low) // 2 if arr[mid] > x: return binary_search(arr, low, mid - 1, x) else: return binary_search(arr, mid + 1, high, x) else: return low #Function call n = int(input()) elementsArray = [int(item) for item in input().split()] c = int(input()) querysArray = [] for i in range(0, c): querysArray.append(int(input())) resultArray = [0] * c for i in range(0, c): resultArray[i] = binary_search(elementsArray, 0, len(elementsArray)-1, querysArray[i]) for i in resultArray: print(i)