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

Envío 4989

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

  • Autor: diezgo1008
  • Fecha: 2021-10-05 04:36:08 UTC (Hace más de 2 años)
Caso # Resultado Tiempo Memoria
#1
Correcto
0.276 s 12 KBi
#2
Correcto
0.285 s 12 KBi
#3
Correcto
0.138 s 12 KBi
#4
Correcto
0.135 s 13 KBi
#5
Correcto
0.236 s 12 KBi
#6
Correcto
0.138 s 12 KBi
#7
Correcto
0.156 s 13 KBi
#8
Correcto
0.173 s 14 KBi
#9
Correcto
0.178 s 13 KBi
#10
Correcto
0.33 s 13 KBi
Puntos totales: 100 / 100

Código

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int elementos = sc.nextInt();
        int cont;

        int[] n = new int[elementos];

        for (int i = 0; i < n.length; i++) {
            n[i] = sc.nextInt();
        }
        int consultas = sc.nextInt();

        int[] c = new int[consultas];
        for (int i = 0; i < c.length; i++) {
            c[i] = sc.nextInt();
        }
        for (int i = 0; i < c.length; i++) {
            cont = 0;
            int actulizar_consultas = c[i];
            for (int j = 0; j < n.length; j++) {
                if (actulizar_consultas < n[j]) {
                    cont++;
                }
            }
            System.out.println(cont);
        }

    }
}