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

Envío 2429

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

  • Autor: wesly
  • Fecha: 2020-12-18 04:04:51 UTC (Hace más de 3 años)
Caso # Resultado Tiempo Memoria
#1
Correcto
0.169 s 16 KBi
#2
Correcto
0.157 s 15 KBi
#3
Correcto
0.143 s 15 KBi
#4
Correcto
0.151 s 16 KBi
#5
Correcto
0.183 s 22 KBi
#6
Correcto
0.163 s 16 KBi
#7
Correcto
0.164 s 16 KBi
#8
Correcto
0.207 s 16 KBi
#9
Correcto
0.168 s 16 KBi
#10
Correcto
0.213 s 23 KBi
Puntos totales: 100 / 100

Código

import java.util.Scanner;

/**
 *
 * @author usuario
 */
public class Main {

    public static void main(String[] args) throws java.lang.Exception {
        Scanner sc = new Scanner(System.in);
        int size = sc.nextInt();
        int[] array = new int[size];
        
        for(int i=0; i<size; i++){
            int num = sc.nextInt();
            array[i] = num;
        }
        
        int querySize = sc.nextInt();
        int[] queries = new int[querySize];
        
        for(int i=0; i< querySize; i++){
            int num = sc.nextInt();
            queries[i] = num;
        }
        
        int[] result = new int[querySize];
        for(int i=0; i<queries.length; i++){
            int temp = 0;
            for(int j = 0; j<array.length; j++){
                if(array[j] > queries[i]){
                    temp++;
                }
            }
            result[i] = temp;
        }
        
        for(int i=0; i<result.length; i++){
            System.out.println(result[i]);
        }
    }
}