Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.155 s | 16 KBi |
#2 |
Correcto
|
0.139 s | 16 KBi |
#3 |
Incorrecto
|
0.142 s | 15 KBi |
#4 |
Correcto
|
0.157 s | 16 KBi |
#5 |
Correcto
|
0.29 s | 12 KBi |
#6 |
Correcto
|
0.137 s | 16 KBi |
#7 |
Correcto
|
0.147 s | 15 KBi |
#8 |
Correcto
|
0.132 s | 16 KBi |
#9 |
Correcto
|
0.178 s | 15 KBi |
#10 |
Correcto
|
0.17 s | 16 KBi |
#11 |
Correcto
|
0.172 s | 16 KBi |
#12 |
Correcto
|
0.161 s | 16 KBi |
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 resp = isOrdered(size, entries) ? "Ordenado" : "Desordenado"; System.out.println(resp); } private static boolean isOrdered(int size, List<Integer> list) { int min = 0; boolean isOrdered = true; for (int i = 1 ; i < list.size(); i++) { min = list.get(0); if(list.get(i) < min) { isOrdered = false; break; } min = list.get(i); } return isOrdered; } }