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

Envío 4697

Problema 0x9d - ¿Está ordenado?

  • Autor: cams2692
  • Fecha: 2021-08-09 20:44:13 UTC (Hace más de 2 años)
Caso # Resultado Tiempo Memoria
#1
Error en tiempo de ejecución (NZEC)
Exited with error status 2
panic: runtime error: index out of range [5] with length 5

goroutine 1 [running]:
main.main()
	/box/main.go:24 +0x495
0.005 s 7 KBi
#2
Correcto
0.004 s 6 KBi
#3
Correcto
0.005 s 6 KBi
#4
Correcto
0.005 s 7 KBi
#5
Correcto
0.004 s 6 KBi
#6
Error en tiempo de ejecución (NZEC)
Exited with error status 2
panic: runtime error: index out of range [10] with length 10

goroutine 1 [running]:
main.main()
	/box/main.go:24 +0x495
0.004 s 6 KBi
#7
Error en tiempo de ejecución (NZEC)
Exited with error status 2
panic: runtime error: index out of range [10] with length 10

goroutine 1 [running]:
main.main()
	/box/main.go:24 +0x495
0.006 s 5 KBi
#8
Error en tiempo de ejecución (NZEC)
Exited with error status 2
panic: runtime error: index out of range [10] with length 10

goroutine 1 [running]:
main.main()
	/box/main.go:24 +0x495
0.004 s 7 KBi
#9
Correcto
0.005 s 6 KBi
#10
Correcto
0.007 s 6 KBi
#11
Incorrecto
0.004 s 8 KBi
#12
Incorrecto
0.004 s 6 KBi
Puntos totales: 50 / 100

Código

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	reader := bufio.NewReader(os.Stdin)

	data, _ := reader.ReadString('\n')
	data = strings.ReplaceAll(data, "\n", "")
	data2, _ := reader.ReadString('\n')
	data2 = strings.ReplaceAll(data2, "\n", "")
	lenght, _ := strconv.ParseInt(data, 10, 0)
	number1 := 0
	number2 := lenght - 1
	numbers := strings.Split(data2, " ")
	for number1 <= int(number2){
		numberFirst := numbers[number1]
		numberSecond := numbers[number1+1]
		if numberFirst > numberSecond {
			fmt.Println("Desordenado")
			return
		}
		number1++
	}

	fmt.Println("Ordenado")

}