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

Envío 5094

Problema 0x9d - ¿Está ordenado?

  • Autor: jarangolp
  • Fecha: 2021-10-14 00:18:35 UTC (Hace más de 2 años)
Caso # Resultado Tiempo Memoria
#1
Incorrecto
0.061 s 6 KBi
#2
Incorrecto
0.056 s 6 KBi
#3
Incorrecto
0.055 s 8 KBi
#4
Incorrecto
0.065 s 6 KBi
#5
Incorrecto
0.051 s 8 KBi
#6
Incorrecto
0.066 s 6 KBi
#7
Incorrecto
0.052 s 6 KBi
#8
Incorrecto
0.052 s 6 KBi
#9
Incorrecto
0.07 s 9 KBi
#10
Incorrecto
0.064 s 7 KBi
#11
Incorrecto
0.051 s 9 KBi
#12
Incorrecto
0.064 s 6 KBi
Puntos totales: 0 / 100

Código

const readline = require('readline');

const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout
});
let ordenado = true;
rl.question('', (n) => {
  rl.question('', (numbersString) => {
    const numbers = numbersString.split(' ').map(number => Number(number));
    console.log(numbers.length);
    if (numbers.length > 1) {
      for(let i = 0; i < numbers.length - 1; i++) {
        if (numbers[i] > numbers[i+1]) {
          ordenado = false;
          break;
        }
      }
    }
    console.log(ordenado ? 'Ordenado' : 'Desordenado');
    rl.close();
  });
});