█████████ ████ ███░░░░░███ ░░███ ███ ░░░ ██████ ███████ ██████ ██████ ░███ ███░░███ ███░░███ ███░░███ ███░░███ ░███ ░███ ░███░███ ░███ ░███████ ░███ ░███ ░░███ ███░███ ░███░███ ░███ ░███░░░ ░███ ░███ ░░█████████ ░░██████ ░░████████░░██████ ░░██████ ░░░░░░░░░ ░░░░░░ ░░░░░░░░ ░░░░░░ ░░░░░░

Envío 7095

Problema 0x63 - Encontrar el primer elemento mayor a X en un arreglo ordenado

Caso # Resultado Tiempo Memoria
#1
Error en tiempo de ejecución (NZEC)
Exited with error status 1
  File "script.py", line 12
    else:
        ^
TabError: inconsistent use of tabs and spaces in indentation
0.016 s 3 KBi
#2
Error en tiempo de ejecución (NZEC)
Exited with error status 1
  File "script.py", line 12
    else:
        ^
TabError: inconsistent use of tabs and spaces in indentation
0.018 s 3 KBi
#3
Error en tiempo de ejecución (NZEC)
Exited with error status 1
  File "script.py", line 12
    else:
        ^
TabError: inconsistent use of tabs and spaces in indentation
0.014 s 3 KBi
#4
Error en tiempo de ejecución (NZEC)
Exited with error status 1
  File "script.py", line 12
    else:
        ^
TabError: inconsistent use of tabs and spaces in indentation
0.016 s 3 KBi
#5
Error en tiempo de ejecución (NZEC)
Exited with error status 1
  File "script.py", line 12
    else:
        ^
TabError: inconsistent use of tabs and spaces in indentation
0.015 s 3 KBi
#6
Error en tiempo de ejecución (NZEC)
Exited with error status 1
  File "script.py", line 12
    else:
        ^
TabError: inconsistent use of tabs and spaces in indentation
0.018 s 3 KBi
#7
Error en tiempo de ejecución (NZEC)
Exited with error status 1
  File "script.py", line 12
    else:
        ^
TabError: inconsistent use of tabs and spaces in indentation
0.014 s 3 KBi
#8
Error en tiempo de ejecución (NZEC)
Exited with error status 1
  File "script.py", line 12
    else:
        ^
TabError: inconsistent use of tabs and spaces in indentation
0.016 s 3 KBi
#9
Error en tiempo de ejecución (NZEC)
Exited with error status 1
  File "script.py", line 12
    else:
        ^
TabError: inconsistent use of tabs and spaces in indentation
0.019 s 3 KBi
#10
Error en tiempo de ejecución (NZEC)
Exited with error status 1
  File "script.py", line 12
    else:
        ^
TabError: inconsistent use of tabs and spaces in indentation
0.015 s 3 KBi
#11
Error en tiempo de ejecución (NZEC)
Exited with error status 1
  File "script.py", line 12
    else:
        ^
TabError: inconsistent use of tabs and spaces in indentation
0.023 s 3 KBi
#12
Error en tiempo de ejecución (NZEC)
Exited with error status 1
  File "script.py", line 12
    else:
        ^
TabError: inconsistent use of tabs and spaces in indentation
0.028 s 3 KBi
#13
Error en tiempo de ejecución (NZEC)
Exited with error status 1
  File "script.py", line 12
    else:
        ^
TabError: inconsistent use of tabs and spaces in indentation
0.015 s 3 KBi
#14
Error en tiempo de ejecución (NZEC)
Exited with error status 1
  File "script.py", line 12
    else:
        ^
TabError: inconsistent use of tabs and spaces in indentation
0.018 s 3 KBi
#15
Error en tiempo de ejecución (NZEC)
Exited with error status 1
  File "script.py", line 12
    else:
        ^
TabError: inconsistent use of tabs and spaces in indentation
0.018 s 3 KBi
#16
Error en tiempo de ejecución (NZEC)
Exited with error status 1
  File "script.py", line 12
    else:
        ^
TabError: inconsistent use of tabs and spaces in indentation
0.02 s 3 KBi
#17
Error en tiempo de ejecución (NZEC)
Exited with error status 1
  File "script.py", line 12
    else:
        ^
TabError: inconsistent use of tabs and spaces in indentation
0.019 s 3 KBi
Puntos totales: 0 / 100

Código

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)
    elif high == low:
    	if arr[len(arr) - 1] > x:
            return high
        else:
            return len(arr)
    else:
        # Element is not present in the array
        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)