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

Envío 5000

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

  • Autor: cams2692
  • Fecha: 2021-10-06 17:57:55 UTC (Hace más de 2 años)
Caso # Resultado Tiempo Memoria
#1
Correcto
0.006 s 3 KBi
#2
Incorrecto
0.011 s 4 KBi
#3
Incorrecto
0.04 s 4 KBi
#4
Tiempo límite excedido
1.117 s 9 KBi
#5
Tiempo límite excedido
1.104 s 9 KBi
#6
Tiempo límite excedido
1.052 s 25 KBi
#7
Tiempo límite excedido
1.036 s 23 KBi
#8
Tiempo límite excedido
1.142 s 20 KBi
Puntos totales: 13 / 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))

	}

}