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

Envío 4604

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

  • Autor: 7yrionLannister
  • Fecha: 2021-08-01 19:27:40 UTC (Hace más de 2 años)
Caso # Resultado Tiempo Memoria
#1
Correcto
0.125 s 14 KBi
#2
Correcto
0.153 s 13 KBi
#3
Correcto
0.127 s 14 KBi
#4
Correcto
0.136 s 14 KBi
#5
Correcto
0.13 s 13 KBi
#6
Correcto
0.161 s 13 KBi
#7
Correcto
0.153 s 14 KBi
#8
Correcto
0.161 s 14 KBi
#9
Correcto
0.149 s 14 KBi
#10
Correcto
0.165 s 14 KBi
Puntos totales: 100 / 100

Código

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = Integer.parseInt(s.nextLine());
        String[] numsS = s.nextLine().split(" ");
        int[] nums = new int[n];
        for (int i = 0; i < n; i++) {
            nums[i] = Integer.parseInt(numsS[i]);
        }
        int q = Integer.parseInt(s.nextLine());
        while (q > 0) {
            int num = Integer.parseInt(s.nextLine());
            int count = 0;
            for (int i : nums) {
                if (i > num) {
                    count++;
                }
            }
            System.out.println(count);
            q--;
        }
    }

}