Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.138 s | 16 KBi |
#2 |
Correcto
|
0.145 s | 16 KBi |
#3 |
Incorrecto
|
0.148 s | 15 KBi |
#4 |
Correcto
|
0.151 s | 15 KBi |
#5 |
Correcto
|
0.353 s | 12 KBi |
#6 |
Correcto
|
0.168 s | 16 KBi |
#7 |
Correcto
|
0.159 s | 16 KBi |
#8 |
Correcto
|
0.159 s | 15 KBi |
#9 |
Correcto
|
0.165 s | 16 KBi |
#10 |
Correcto
|
0.168 s | 15 KBi |
#11 |
Correcto
|
0.145 s | 16 KBi |
#12 |
Correcto
|
0.165 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<Long> entries = new ArrayList<>(); for (int i = 0; i < size; i++) { long 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<Long> list) { long 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; } }