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

Envío 1081

Problema 0x9d - ¿Está ordenado?

  • Autor: datruq
  • Fecha: 2020-10-09 19:42:10 UTC (Hace alrededor de 4 años)
Caso # Resultado Tiempo Memoria
#1
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Error: Could not find or load main class Main
Caused by: java.lang.NoClassDefFoundError: com/david/test/Main (wrong name: Main)
0.096 s 10 KBi
#2
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Error: Could not find or load main class Main
Caused by: java.lang.NoClassDefFoundError: com/david/test/Main (wrong name: Main)
0.091 s 11 KBi
#3
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Error: Could not find or load main class Main
Caused by: java.lang.NoClassDefFoundError: com/david/test/Main (wrong name: Main)
0.108 s 12 KBi
#4
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Error: Could not find or load main class Main
Caused by: java.lang.NoClassDefFoundError: com/david/test/Main (wrong name: Main)
0.097 s 13 KBi
#5
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Error: Could not find or load main class Main
Caused by: java.lang.NoClassDefFoundError: com/david/test/Main (wrong name: Main)
0.097 s 11 KBi
#6
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Error: Could not find or load main class Main
Caused by: java.lang.NoClassDefFoundError: com/david/test/Main (wrong name: Main)
0.103 s 11 KBi
#7
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Error: Could not find or load main class Main
Caused by: java.lang.NoClassDefFoundError: com/david/test/Main (wrong name: Main)
0.096 s 11 KBi
#8
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Error: Could not find or load main class Main
Caused by: java.lang.NoClassDefFoundError: com/david/test/Main (wrong name: Main)
0.095 s 11 KBi
#9
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Error: Could not find or load main class Main
Caused by: java.lang.NoClassDefFoundError: com/david/test/Main (wrong name: Main)
0.099 s 11 KBi
#10
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Error: Could not find or load main class Main
Caused by: java.lang.NoClassDefFoundError: com/david/test/Main (wrong name: Main)
0.1 s 11 KBi
#11
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Error: Could not find or load main class Main
Caused by: java.lang.NoClassDefFoundError: com/david/test/Main (wrong name: Main)
0.106 s 11 KBi
#12
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Error: Could not find or load main class Main
Caused by: java.lang.NoClassDefFoundError: com/david/test/Main (wrong name: Main)
0.094 s 10 KBi
Puntos totales: 0 / 100

Código

package com.david.test;

import java.util.ArrayList;
import java.util.List;
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(" ");
        List<Integer> entries = new ArrayList<>();
        for (int i = 0; i < size; i++) {
            int arItem = Integer.parseInt(arItems[i]);
            entries.add(arItem);
        }
        String respuesta = ordernar(size, entries) ? "Ordenado" : "Desordenado";
        System.out.println(respuesta);
    }

    private static boolean ordernar(int size, List<Integer> list) {
        int min = 0;
        boolean isOrdered = false;
        for(int i : list) {
            if(i<min) return false;
            min = i;
        }
        return true;
    }
}