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

Envío 5779

Problema 0x9d - ¿Está ordenado?

  • Autor: pablopvsky
  • Fecha: 2022-02-28 02:48:16 UTC (Hace alrededor de 2 años)
Caso # Resultado Tiempo Memoria
#1
Correcto
0.091 s 16 KBi
#2
Correcto
0.121 s 12 KBi
#3
Correcto
0.098 s 17 KBi
#4
Correcto
0.101 s 16 KBi
#5
Correcto
0.145 s 13 KBi
#6
Correcto
0.078 s 16 KBi
#7
Correcto
0.081 s 16 KBi
#8
Correcto
0.08 s 16 KBi
#9
Correcto
0.086 s 16 KBi
#10
Correcto
0.107 s 16 KBi
#11
Correcto
0.11 s 16 KBi
#12
Correcto
0.089 s 16 KBi
Puntos totales: 100 / 100

Código

import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) {
        Scanner line = new Scanner(System.in);
        Boolean listVerify[];
        int lineNumber = 0;
        int listLengthInputInt = 0;

        while (line.hasNextLine()) {
            if (lineNumber == 0) {
                String listLengthInput = line.nextLine();
                listLengthInputInt = Integer.parseInt(listLengthInput);
                lineNumber++;
            } else {
                String[] numbersList = line.nextLine().split("\\s");
                listVerify = new Boolean[listLengthInputInt];

                for (int index = 0; index < listLengthInputInt - 1; index++) {
                    Integer firstNumber = Integer.valueOf(numbersList[index]);
                    Integer secondNumber = Integer.valueOf(numbersList[(index + 1)]);
                    if (firstNumber > secondNumber) {
                        System.out.println("Desordenado");
                        return;
                    }
                }
                System.out.println("Ordenado");
            }
        }

        line.close();
    }
}