Envío 6828
- Autor: sur
- Fecha: 2022-12-22 21:22:45 UTC (Hace alrededor de 1 mes)
Caso # |
Resultado |
Tiempo |
Memoria |
#1 |

Correcto
|
0.016 s
|
3 KBi |
#2 |

Correcto
|
0.018 s
|
3 KBi |
#3 |

Correcto
|
0.017 s
|
3 KBi |
#4 |

Correcto
|
0.015 s
|
3 KBi |
#5 |

Correcto
|
0.015 s
|
3 KBi |
#6 |

Correcto
|
0.018 s
|
3 KBi |
#7 |

Correcto
|
0.018 s
|
3 KBi |
#8 |

Correcto
|
0.017 s
|
3 KBi |
#9 |

Correcto
|
0.02 s
|
3 KBi |
#10 |

Correcto
|
0.022 s
|
3 KBi |
Puntos totales: 100 / 100
Código
n = int(input())
elements = list(map(int, input().split()))
# Read the number of queries
c = int(input())
# Sort the array in ascending order
elements.sort()
# Process each query
for i in range(c):
# Read the query value
x = int(input())
# Find the index of the first element greater than x using binary search
left = 0
right = n - 1
while left <= right:
mid = (left + right) // 2
if elements[mid] <= x:
left = mid + 1
else:
right = mid - 1
first_greater = left
# The number of elements greater than x is the total number of elements minus the index of the first element greater than x
count = n - first_greater
print(count)