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

Envío 1445

Problema 0x9d - ¿Está ordenado?

  • Autor: c4rlosc7
  • Fecha: 2020-10-27 01:41:32 UTC (Hace más de 3 años)
Caso # Resultado Tiempo Memoria
#1
Correcto
0.12 s 13 KBi
#2
Correcto
0.122 s 13 KBi
#3
Correcto
0.137 s 13 KBi
#4
Correcto
0.119 s 13 KBi
#5
Correcto
0.122 s 13 KBi
#6
Correcto
0.135 s 13 KBi
#7
Correcto
0.136 s 13 KBi
#8
Correcto
0.125 s 13 KBi
#9
Correcto
0.13 s 14 KBi
#10
Correcto
0.143 s 14 KBi
#11
Correcto
0.15 s 13 KBi
#12
Correcto
0.133 s 13 KBi
Puntos totales: 100 / 100

Código

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		if (n > 0 && n < 1000) {
			int [] a = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = sc.nextInt();
			}
	
			boolean sorted = true;
			for (int i = 0; i + 1 < n; i++) {
				sorted = sorted && (a[i] <= a[i + 1]);
			}
	
			if (sorted == true) {
				System.out.println("Ordenado");
			} else {
				System.out.println("Desordenado");
			}
		} else {
			System.out.println("Number out of range");
		}

	}
}