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

Envío 5892

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

  • Autor: cams2692
  • Fecha: 2022-03-23 15:21:39 UTC (Hace más de 2 años)
Caso # Resultado Tiempo Memoria
#1
Incorrecto
0.003 s 4 KBi
#2
Incorrecto
0.002 s 4 KBi
#3
Correcto
0.004 s 4 KBi
#4
Incorrecto
0.004 s 4 KBi
#5
Incorrecto
0.005 s 4 KBi
#6
Incorrecto
0.004 s 4 KBi
#7
Incorrecto
0.003 s 5 KBi
#8
Incorrecto
0.004 s 5 KBi
#9
Incorrecto
0.004 s 53 KBi
#10
Incorrecto
0.01 s 5 KBi
#11
Incorrecto
0.032 s 12 KBi
#12
Incorrecto
0.014 s 12 KBi
#13
Incorrecto
0.028 s 12 KBi
Puntos totales: 8 / 100

Código

package main

import (
	"bufio"
	"fmt"
	"os"
	"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]
		var position int64 = l
		var height int64 = 0

		for j, val := range data {
			if val > height {
				position = int64(j) + l

			}
		}

		fmt.Println(position)

	}

}