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

Envío 5891

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

  • Autor: cams2692
  • Fecha: 2022-03-23 15:16:06 UTC (Hace más de 2 años)
Caso # Resultado Tiempo Memoria
#1
Incorrecto
0.002 s 4 KBi
#2
Incorrecto
0.002 s 4 KBi
#3
Incorrecto
0.004 s 5 KBi
#4
Incorrecto
0.004 s 5 KBi
#5
Incorrecto
0.01 s 4 KBi
#6
Incorrecto
0.003 s 4 KBi
#7
Incorrecto
0.002 s 4 KBi
#8
Incorrecto
0.003 s 3 KBi
#9
Incorrecto
0.002 s 4 KBi
#10
Incorrecto
0.005 s 4 KBi
#11
Incorrecto
0.016 s 11 KBi
#12
Incorrecto
0.072 s 12 KBi
#13
Incorrecto
0.1 s 12 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+1]
		sort.Slice(data, func(i, j int) bool { return data[i] < data[j] })
		fmt.Println(data[len(data)-1])

	}

}