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

Envío 6827

Problema 0x62 - Contar elementos mayores a X en un arreglo pequeño

  • Autor: sur
  • Fecha: 2022-12-22 21:22:32 UTC (Hace alrededor de 1 mes)
Caso # Resultado Tiempo Memoria
#1
Error de compilación
                      main.c:1:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
n = int(input())
^
main.c:1:5: error: expected expression
n = int(input())
    ^
main.c:4:3: error: invalid preprocessing directive
# Read the number of queries
  ^
main.c:7:3: error: invalid preprocessing directive
# Sort the array in ascending order
  ^
main.c:10:3: error: invalid preprocessing directive
# Process each query
  ^
main.c:12:5: error: invalid preprocessing directive
  # Read the query value
    ^
main.c:15:5: error: invalid preprocessing directive
  # Find the index of the first element greater than x using binary search
    ^
main.c:26:5: error: invalid preprocessing directive
  # The number of elements greater than x is the total number of elements minus the index of the first element greater than x
    ^
main.c:29:15: error: expected ';' after top level declarator
  print(count)
              ^
              ;
1 warning and 8 errors generated.

                    
#2
Error de compilación
                      main.c:1:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
n = int(input())
^
main.c:1:5: error: expected expression
n = int(input())
    ^
main.c:4:3: error: invalid preprocessing directive
# Read the number of queries
  ^
main.c:7:3: error: invalid preprocessing directive
# Sort the array in ascending order
  ^
main.c:10:3: error: invalid preprocessing directive
# Process each query
  ^
main.c:12:5: error: invalid preprocessing directive
  # Read the query value
    ^
main.c:15:5: error: invalid preprocessing directive
  # Find the index of the first element greater than x using binary search
    ^
main.c:26:5: error: invalid preprocessing directive
  # The number of elements greater than x is the total number of elements minus the index of the first element greater than x
    ^
main.c:29:15: error: expected ';' after top level declarator
  print(count)
              ^
              ;
1 warning and 8 errors generated.

                    
#3
Error de compilación
                      main.c:1:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
n = int(input())
^
main.c:1:5: error: expected expression
n = int(input())
    ^
main.c:4:3: error: invalid preprocessing directive
# Read the number of queries
  ^
main.c:7:3: error: invalid preprocessing directive
# Sort the array in ascending order
  ^
main.c:10:3: error: invalid preprocessing directive
# Process each query
  ^
main.c:12:5: error: invalid preprocessing directive
  # Read the query value
    ^
main.c:15:5: error: invalid preprocessing directive
  # Find the index of the first element greater than x using binary search
    ^
main.c:26:5: error: invalid preprocessing directive
  # The number of elements greater than x is the total number of elements minus the index of the first element greater than x
    ^
main.c:29:15: error: expected ';' after top level declarator
  print(count)
              ^
              ;
1 warning and 8 errors generated.

                    
#4
Error de compilación
                      main.c:1:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
n = int(input())
^
main.c:1:5: error: expected expression
n = int(input())
    ^
main.c:4:3: error: invalid preprocessing directive
# Read the number of queries
  ^
main.c:7:3: error: invalid preprocessing directive
# Sort the array in ascending order
  ^
main.c:10:3: error: invalid preprocessing directive
# Process each query
  ^
main.c:12:5: error: invalid preprocessing directive
  # Read the query value
    ^
main.c:15:5: error: invalid preprocessing directive
  # Find the index of the first element greater than x using binary search
    ^
main.c:26:5: error: invalid preprocessing directive
  # The number of elements greater than x is the total number of elements minus the index of the first element greater than x
    ^
main.c:29:15: error: expected ';' after top level declarator
  print(count)
              ^
              ;
1 warning and 8 errors generated.

                    
#5
Error de compilación
                      main.c:1:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
n = int(input())
^
main.c:1:5: error: expected expression
n = int(input())
    ^
main.c:4:3: error: invalid preprocessing directive
# Read the number of queries
  ^
main.c:7:3: error: invalid preprocessing directive
# Sort the array in ascending order
  ^
main.c:10:3: error: invalid preprocessing directive
# Process each query
  ^
main.c:12:5: error: invalid preprocessing directive
  # Read the query value
    ^
main.c:15:5: error: invalid preprocessing directive
  # Find the index of the first element greater than x using binary search
    ^
main.c:26:5: error: invalid preprocessing directive
  # The number of elements greater than x is the total number of elements minus the index of the first element greater than x
    ^
main.c:29:15: error: expected ';' after top level declarator
  print(count)
              ^
              ;
1 warning and 8 errors generated.

                    
#6
Error de compilación
                      main.c:1:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
n = int(input())
^
main.c:1:5: error: expected expression
n = int(input())
    ^
main.c:4:3: error: invalid preprocessing directive
# Read the number of queries
  ^
main.c:7:3: error: invalid preprocessing directive
# Sort the array in ascending order
  ^
main.c:10:3: error: invalid preprocessing directive
# Process each query
  ^
main.c:12:5: error: invalid preprocessing directive
  # Read the query value
    ^
main.c:15:5: error: invalid preprocessing directive
  # Find the index of the first element greater than x using binary search
    ^
main.c:26:5: error: invalid preprocessing directive
  # The number of elements greater than x is the total number of elements minus the index of the first element greater than x
    ^
main.c:29:15: error: expected ';' after top level declarator
  print(count)
              ^
              ;
1 warning and 8 errors generated.

                    
#7
Error de compilación
                      main.c:1:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
n = int(input())
^
main.c:1:5: error: expected expression
n = int(input())
    ^
main.c:4:3: error: invalid preprocessing directive
# Read the number of queries
  ^
main.c:7:3: error: invalid preprocessing directive
# Sort the array in ascending order
  ^
main.c:10:3: error: invalid preprocessing directive
# Process each query
  ^
main.c:12:5: error: invalid preprocessing directive
  # Read the query value
    ^
main.c:15:5: error: invalid preprocessing directive
  # Find the index of the first element greater than x using binary search
    ^
main.c:26:5: error: invalid preprocessing directive
  # The number of elements greater than x is the total number of elements minus the index of the first element greater than x
    ^
main.c:29:15: error: expected ';' after top level declarator
  print(count)
              ^
              ;
1 warning and 8 errors generated.

                    
#8
Error de compilación
                      main.c:1:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
n = int(input())
^
main.c:1:5: error: expected expression
n = int(input())
    ^
main.c:4:3: error: invalid preprocessing directive
# Read the number of queries
  ^
main.c:7:3: error: invalid preprocessing directive
# Sort the array in ascending order
  ^
main.c:10:3: error: invalid preprocessing directive
# Process each query
  ^
main.c:12:5: error: invalid preprocessing directive
  # Read the query value
    ^
main.c:15:5: error: invalid preprocessing directive
  # Find the index of the first element greater than x using binary search
    ^
main.c:26:5: error: invalid preprocessing directive
  # The number of elements greater than x is the total number of elements minus the index of the first element greater than x
    ^
main.c:29:15: error: expected ';' after top level declarator
  print(count)
              ^
              ;
1 warning and 8 errors generated.

                    
#9
Error de compilación
                      main.c:1:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
n = int(input())
^
main.c:1:5: error: expected expression
n = int(input())
    ^
main.c:4:3: error: invalid preprocessing directive
# Read the number of queries
  ^
main.c:7:3: error: invalid preprocessing directive
# Sort the array in ascending order
  ^
main.c:10:3: error: invalid preprocessing directive
# Process each query
  ^
main.c:12:5: error: invalid preprocessing directive
  # Read the query value
    ^
main.c:15:5: error: invalid preprocessing directive
  # Find the index of the first element greater than x using binary search
    ^
main.c:26:5: error: invalid preprocessing directive
  # The number of elements greater than x is the total number of elements minus the index of the first element greater than x
    ^
main.c:29:15: error: expected ';' after top level declarator
  print(count)
              ^
              ;
1 warning and 8 errors generated.

                    
#10
Error de compilación
                      main.c:1:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
n = int(input())
^
main.c:1:5: error: expected expression
n = int(input())
    ^
main.c:4:3: error: invalid preprocessing directive
# Read the number of queries
  ^
main.c:7:3: error: invalid preprocessing directive
# Sort the array in ascending order
  ^
main.c:10:3: error: invalid preprocessing directive
# Process each query
  ^
main.c:12:5: error: invalid preprocessing directive
  # Read the query value
    ^
main.c:15:5: error: invalid preprocessing directive
  # Find the index of the first element greater than x using binary search
    ^
main.c:26:5: error: invalid preprocessing directive
  # The number of elements greater than x is the total number of elements minus the index of the first element greater than x
    ^
main.c:29:15: error: expected ';' after top level declarator
  print(count)
              ^
              ;
1 warning and 8 errors generated.

                    
Puntos totales: 0 / 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)