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

Envío 4235

Problema 0x9d - ¿Está ordenado?

  • Autor: andres0608
  • Fecha: 2021-05-30 00:06:05 UTC (Hace casi 3 años)
Caso # Resultado Tiempo Memoria
#1
Incorrecto
0.152 s 13 KBi
#2
Correcto
0.163 s 14 KBi
#3
Correcto
0.146 s 13 KBi
#4
Correcto
0.207 s 13 KBi
#5
Correcto
0.156 s 14 KBi
#6
Incorrecto
0.166 s 16 KBi
#7
Incorrecto
0.146 s 13 KBi
#8
Incorrecto
0.206 s 13 KBi
#9
Correcto
0.187 s 15 KBi
#10
Correcto
0.203 s 15 KBi
#11
Incorrecto
0.189 s 14 KBi
#12
Incorrecto
0.295 s 16 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 < Integer.parseInt(numero1); i++){
for (int j=0; j < Integer.parseInt(numero1); 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");   

}
}