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

Envío 4973

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

  • Autor: martinarriaga
  • Fecha: 2021-10-02 22:18:28 UTC (Hace más de 2 años)
Caso # Resultado Tiempo Memoria
#1
Correcto
0.313 s 13 KBi
#2
Correcto
0.131 s 14 KBi
#3
Correcto
0.161 s 12 KBi
#4
Correcto
0.172 s 12 KBi
#5
Correcto
0.165 s 12 KBi
#6
Correcto
0.131 s 12 KBi
#7
Correcto
0.424 s 13 KBi
#8
Correcto
0.143 s 12 KBi
#9
Correcto
0.199 s 13 KBi
#10
Correcto
0.144 s 12 KBi
Puntos totales: 100 / 100

Código

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] numeros = new int[n];
        for (int i = 0; i < n; i++)
        {
             numeros[i] = scanner.nextInt();
        }
        int c = scanner.nextInt();
        int[] consultas = new int[c];
        for (int i = 0; i < c; i++)
        {
            consultas[i] = scanner.nextInt();
        }
        int cont;
        for (int i = 0; i < c; i++)
        {
            cont = 0;
            int consultaActual = consultas[i];
            for (int j = 0; j < n; j++)
            {
                if(consultaActual < numeros[j])
                {
                    cont++;
                }
            }
            System.out.println(cont);
        }

        
    }
}