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

Envío 5001

Problema 0xca - Contar cuantas veces aparece X en un subarreglo

  • Autor: cams2692
  • Fecha: 2021-10-06 17:59:22 UTC (Hace más de 2 años)
Caso # Resultado Tiempo Memoria
#1
Correcto
0.017 s 3 KBi
#2
Incorrecto
0.005 s 3 KBi
#3
Correcto
0.06 s 4 KBi
#4
Tiempo límite excedido
1.041 s 12 KBi
#5
Tiempo límite excedido
1.009 s 12 KBi
#6
Tiempo límite excedido
1.061 s 23 KBi
#7
Tiempo límite excedido
1.057 s 29 KBi
#8
Tiempo límite excedido
1.154 s 19 KBi
Puntos totales: 25 / 100

Código

package main

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

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

	n, _ := reader.ReadString('\n')
	n = strings.ReplaceAll(n, "\n", "")
	nArray, _ := reader.ReadString('\n')
	nArray = strings.ReplaceAll(nArray, "\n", "")
	numbers := strings.Split(nArray, " ")
	c, _ := reader.ReadString('\n')
	c = strings.ReplaceAll(c, "\n", "")
	cNumber, _ := strconv.ParseInt(c, 10, 64)
	for i := 0; i < int(cNumber); i++ {
		caseLine, _ := reader.ReadString('\n')
		caseLine = strings.ReplaceAll(caseLine, "\n", "")
		numbersCase := strings.Split(caseLine, " ")
		numberOne, _ := strconv.ParseInt(numbersCase[0], 10, 64)
		numberTwo, _ := strconv.ParseInt(numbersCase[1], 10, 64)
		numberSearch := numbersCase[2]
		sliceNumber := strings.Join(numbers[numberOne:numberTwo+1], " ")

		fmt.Println(strings.Count(sliceNumber, numberSearch))

	}

}