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

Envío 4233

Problema 0x9d - ¿Está ordenado?

  • Autor: andres0608
  • Fecha: 2021-05-30 00:03:14 UTC (Hace casi 3 años)
Caso # Resultado Tiempo Memoria
#1
Incorrecto
0.26 s 15 KBi
#2
Correcto
0.162 s 15 KBi
#3
Correcto
0.161 s 14 KBi
#4
Correcto
0.241 s 14 KBi
#5
Correcto
0.145 s 13 KBi
#6
Incorrecto
0.153 s 14 KBi
#7
Incorrecto
0.144 s 14 KBi
#8
Incorrecto
0.169 s 15 KBi
#9
Correcto
0.191 s 14 KBi
#10
Correcto
0.318 s 15 KBi
#11
Incorrecto
0.201 s 15 KBi
#12
Incorrecto
0.23 s 14 KBi
Puntos totales: 50 / 100

Código

import java.util.*;
public class Main {

public static void main(String[] args) {
String  numero1, numero2;
Scanner numeros = new Scanner(System.in);
numero1 = numeros.nextLine();
numero2="";
numero2 += numeros.nextLine();
numeros.close();

String[] numbers = numero2.split(" ");
String temp;


for (int i=0; i < numbers.length; i++){
for (int j=0; j < numbers.length; j++){	
if(Integer.parseInt(numbers[j])  > Integer.parseInt(numbers[i])){
temp = numbers[i];
numbers[i] = numbers[j];
numbers[j] = temp;
}
}

}
String valores="";
for(int k=0;k < numbers.length; k++){
valores+=numbers[k] + " ";
}

System.out.println((numero2.equals(valores.trim()))?"Ordernado":"Desordenado");   

}
}