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

Envío 3313

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

  • Autor: datruq
  • Fecha: 2021-03-09 06:01:04 UTC (Hace casi 4 años)
Caso # Resultado Tiempo Memoria
#1
Error de compilación
                      Main.java:3: error: class MainTemplate is public, should be declared in a file named MainTemplate.java
public class MainTemplate {
       ^
1 error

                    
#2
Error de compilación
                      Main.java:3: error: class MainTemplate is public, should be declared in a file named MainTemplate.java
public class MainTemplate {
       ^
1 error

                    
#3
Error de compilación
                      Main.java:3: error: class MainTemplate is public, should be declared in a file named MainTemplate.java
public class MainTemplate {
       ^
1 error

                    
#4
Error de compilación
                      Main.java:3: error: class MainTemplate is public, should be declared in a file named MainTemplate.java
public class MainTemplate {
       ^
1 error

                    
#5
Error de compilación
                      Main.java:3: error: class MainTemplate is public, should be declared in a file named MainTemplate.java
public class MainTemplate {
       ^
1 error

                    
#6
Error de compilación
                      Main.java:3: error: class MainTemplate is public, should be declared in a file named MainTemplate.java
public class MainTemplate {
       ^
1 error

                    
#7
Error de compilación
                      Main.java:3: error: class MainTemplate is public, should be declared in a file named MainTemplate.java
public class MainTemplate {
       ^
1 error

                    
#8
Error de compilación
                      Main.java:3: error: class MainTemplate is public, should be declared in a file named MainTemplate.java
public class MainTemplate {
       ^
1 error

                    
#9
Error de compilación
                      Main.java:3: error: class MainTemplate is public, should be declared in a file named MainTemplate.java
public class MainTemplate {
       ^
1 error

                    
#10
Error de compilación
                      Main.java:3: error: class MainTemplate is public, should be declared in a file named MainTemplate.java
public class MainTemplate {
       ^
1 error

                    
Puntos totales: 0 / 100

Código

import java.util.Scanner;

public class MainTemplate {

    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;
        }
    }

}