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

Envío 3314

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

  • Autor: datruq
  • Fecha: 2021-03-09 06:01:32 UTC (Hace alrededor de 3 años)
Caso # Resultado Tiempo Memoria
#1
Correcto
0.168 s 16 KBi
#2
Correcto
0.151 s 16 KBi
#3
Correcto
0.168 s 16 KBi
#4
Correcto
0.168 s 16 KBi
#5
Correcto
0.157 s 15 KBi
#6
Correcto
0.175 s 16 KBi
#7
Correcto
0.185 s 16 KBi
#8
Correcto
0.189 s 16 KBi
#9
Correcto
0.206 s 16 KBi
#10
Correcto
0.223 s 16 KBi
Puntos totales: 100 / 100

Código

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sn = new Scanner(System.in);
        int size = Integer.parseInt(sn.nextLine());
        String[] arItems = sn.nextLine().split(" ");
        int c = Integer.parseInt(sn.nextLine());
        Integer[] xEntries = new Integer[c];
        for (int i = 0; i < c; i++) {
            int arItem = Integer.parseInt(sn.nextLine());
            xEntries[i] = arItem;
        }
        Integer[] entries = new Integer[size];
        for (int i = 0; i < size; i++) {
            int arItem = Integer.parseInt(arItems[i]);
            entries[i] = arItem;
        }
        int count = 0;
        for (int i = 0; i < c; i++) {
            for (int j = 0; j < size; j++) {
                if (xEntries[i] < entries[j]) {
                    ++count;
                }
            }
            System.out.println(count);
            count = 0;
        }
    }

}