Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Error de compilación
Main.java:3: error: class ContarMayores is public, should be declared in a file named ContarMayores.java public class ContarMayores { ^ 1 error |
||
#2 |
Error de compilación
Main.java:3: error: class ContarMayores is public, should be declared in a file named ContarMayores.java public class ContarMayores { ^ 1 error |
||
#3 |
Error de compilación
Main.java:3: error: class ContarMayores is public, should be declared in a file named ContarMayores.java public class ContarMayores { ^ 1 error |
||
#4 |
Error de compilación
Main.java:3: error: class ContarMayores is public, should be declared in a file named ContarMayores.java public class ContarMayores { ^ 1 error |
||
#5 |
Error de compilación
Main.java:3: error: class ContarMayores is public, should be declared in a file named ContarMayores.java public class ContarMayores { ^ 1 error |
||
#6 |
Error de compilación
Main.java:3: error: class ContarMayores is public, should be declared in a file named ContarMayores.java public class ContarMayores { ^ 1 error |
||
#7 |
Error de compilación
Main.java:3: error: class ContarMayores is public, should be declared in a file named ContarMayores.java public class ContarMayores { ^ 1 error |
||
#8 |
Error de compilación
Main.java:3: error: class ContarMayores is public, should be declared in a file named ContarMayores.java public class ContarMayores { ^ 1 error |
||
#9 |
Error de compilación
Main.java:3: error: class ContarMayores is public, should be declared in a file named ContarMayores.java public class ContarMayores { ^ 1 error |
||
#10 |
Error de compilación
Main.java:3: error: class ContarMayores is public, should be declared in a file named ContarMayores.java public class ContarMayores { ^ 1 error |
import java.util.Scanner; public class ContarMayores { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); // Leer la cantidad de elementos en el arreglo int N = scanner.nextInt(); // Leer los elementos del arreglo int[] arreglo = new int[N]; for (int i = 0; i < N; i++) { arreglo[i] = scanner.nextInt(); } // Leer el número de consultas int C = scanner.nextInt(); // Procesar las consultas for (int i = 0; i < C; i++) { int X = scanner.nextInt(); int resultado = contarMayores(arreglo, X); System.out.println(resultado); } } public static int contarMayores(int[] arreglo, int X) { int contador = 0; for (int elemento : arreglo) { if (elemento > X) { contador++; } } return contador; } }