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

Envío 5890

Problema 0x9b - Máximo elemento en un subarreglo pequeño

  • Autor: cams2692
  • Fecha: 2022-03-23 15:14:22 UTC (Hace alrededor 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 [-1]

goroutine 1 [running]:
main.main()
	/box/main.go:39 +0x777
0.005 s 4 KBi
#2
Incorrecto
0.003 s 4 KBi
#3
Error en tiempo de ejecución (NZEC)
Exited with error status 2
panic: runtime error: index out of range [-1]

goroutine 1 [running]:
main.main()
	/box/main.go:39 +0x777
0.002 s 4 KBi
#4
Error en tiempo de ejecución (NZEC)
Exited with error status 2
panic: runtime error: index out of range [-1]

goroutine 1 [running]:
main.main()
	/box/main.go:39 +0x777
0.003 s 4 KBi
#5
Error en tiempo de ejecución (NZEC)
Exited with error status 2
panic: runtime error: index out of range [-1]

goroutine 1 [running]:
main.main()
	/box/main.go:39 +0x777
0.005 s 32 KBi
#6
Error en tiempo de ejecución (NZEC)
Exited with error status 2
panic: runtime error: index out of range [-1]

goroutine 1 [running]:
main.main()
	/box/main.go:39 +0x777
0.006 s 18 KBi
#7
Error en tiempo de ejecución (NZEC)
Exited with error status 2
panic: runtime error: index out of range [-1]

goroutine 1 [running]:
main.main()
	/box/main.go:39 +0x777
0.002 s 4 KBi
#8
Error en tiempo de ejecución (NZEC)
Exited with error status 2
panic: runtime error: index out of range [-1]

goroutine 1 [running]:
main.main()
	/box/main.go:39 +0x777
0.002 s 4 KBi
#9
Error en tiempo de ejecución (NZEC)
Exited with error status 2
panic: runtime error: index out of range [-1]

goroutine 1 [running]:
main.main()
	/box/main.go:39 +0x777
0.002 s 4 KBi
#10
Error en tiempo de ejecución (NZEC)
Exited with error status 2
panic: runtime error: index out of range [-1]

goroutine 1 [running]:
main.main()
	/box/main.go:39 +0x777
0.002 s 4 KBi
#11
Error en tiempo de ejecución (NZEC)
Exited with error status 2
panic: runtime error: index out of range [-1]

goroutine 1 [running]:
main.main()
	/box/main.go:39 +0x777
0.012 s 12 KBi
#12
Error en tiempo de ejecución (NZEC)
Exited with error status 2
panic: runtime error: index out of range [-1]

goroutine 1 [running]:
main.main()
	/box/main.go:39 +0x777
0.033 s 11 KBi
#13
Incorrecto
0.037 s 11 KBi
Puntos totales: 0 / 100

Código

package main

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

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

	reader.ReadString('\n')

	numbers, _ := reader.ReadString('\n')
	numbers = strings.ReplaceAll(numbers, "\n", "")

	numbersSeparate := strings.Split(numbers, " ")
	numbersReal := make([]int64, 0)
	for _, value := range numbersSeparate {
		valNumber, _ := strconv.ParseInt(value, 10, 64)
		numbersReal = append(numbersReal, valNumber)
	}

	cString, _ := reader.ReadString('\n')
	cString = strings.ReplaceAll(cString, "\n", "")
	c, _ := strconv.ParseInt(cString, 10, 64)
	for i := 0; int64(i) < c; i++ {
		lrData, _ := reader.ReadString('\n')
		lrData = strings.ReplaceAll(lrData, "\n", "")
		lrSplit := strings.Split(lrData, " ")
		l, _ := strconv.ParseInt(lrSplit[0], 10, 64)
		r, _ := strconv.ParseInt(lrSplit[1], 10, 64)

		data := numbersReal[l:r]
		sort.Slice(data, func(i, j int) bool { return data[i] < data[j] })
		fmt.Println(data[len(data)-1])

	}

}