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

Envío 6797

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

  • Autor: Aaron Zuñiga
  • Fecha: 2022-12-03 06:27:02 UTC (Hace más de 1 año)
Caso # Resultado Tiempo Memoria
#1
Correcto
0.117 s 13 KBi
#2
Correcto
0.129 s 13 KBi
#3
Correcto
0.122 s 13 KBi
#4
Correcto
0.127 s 13 KBi
#5
Correcto
0.122 s 13 KBi
#6
Correcto
0.129 s 13 KBi
#7
Correcto
0.178 s 13 KBi
#8
Correcto
0.162 s 13 KBi
#9
Correcto
0.145 s 13 KBi
#10
Correcto
0.137 s 13 KBi
Puntos totales: 100 / 100

Código

import java.util.Scanner;

class Main
{
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[n];
        int contador = 0;
        
        for(int i = 0; i < n; i++){
            arr[i] = sc.nextInt();
        }
        
        int c = sc.nextInt();
        for(int j = 0; j < c; j++){
            int x = sc.nextInt();
            for(int k = 0; k < arr.length; k++){
                if(arr[k]>x){
                    contador++;
                }
            }
            System.out.println(contador);
            contador = 0;
        }
    }
}