Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.03 s | 3 KBi |
#2 |
Incorrecto
|
0.031 s | 3 KBi |
#3 |
Correcto
|
0.029 s | 3 KBi |
#4 |
Correcto
|
0.021 s | 3 KBi |
#5 |
Correcto
|
0.027 s | 3 KBi |
#6 |
Incorrecto
|
0.025 s | 3 KBi |
#7 |
Correcto
|
0.025 s | 3 KBi |
#8 |
Correcto
|
0.024 s | 3 KBi |
#9 |
Incorrecto
|
0.023 s | 3 KBi |
#10 |
Incorrecto
|
0.023 s | 3 KBi |
n = int(input()) arr = sorted(list(map(int, input().split(" ")))) def binary_search(arr, low, high, x): if high > low: mid = (high + low) // 2 if arr[mid] == x: return mid elif arr[mid] > x: return binary_search(arr, low, mid - 1, x) else: return binary_search(arr, mid + 1, high, x) else: return -1 c = int(input()) for i in range(0, c): x = int(input()) if arr[-1] <= x: print("0") continue index = binary_search(arr, 0, n, x) if index == -1: print(n) else: for j in range(0, n): if arr[j] > x: print(n - j) break