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

Envío 6884

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

  • Autor: Aaron Zuñiga
  • Fecha: 2023-02-23 03:23:56 UTC (Hace alrededor de 1 mes)
Caso # Resultado Tiempo Memoria
#1
Correcto
0.101 s 13 KBi
#2
Correcto
0.1 s 13 KBi
#3
Correcto
0.101 s 13 KBi
#4
Correcto
0.117 s 13 KBi
#5
Correcto
0.117 s 13 KBi
#6
Correcto
0.099 s 13 KBi
#7
Correcto
0.117 s 13 KBi
#8
Correcto
0.131 s 13 KBi
#9
Correcto
0.155 s 14 KBi
#10
Correcto
0.085 s 17 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 cont = 0;
        
        for(int i = 0; i < n; i++){
            arr[i] = sc.nextInt();
        }
        
        int c = sc.nextInt();
        for(int i = 0; i < c; i++){
            int x = sc.nextInt();
            for(int j = 0; j < arr.length; j++){
                if(arr[j] > x){
                    cont++;
                }
            }
            System.out.println(cont);
            cont = 0;   
        }
    }
}