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

Envío 5127

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

  • Autor: Andres Ariza
  • Fecha: 2021-10-18 22:47:34 UTC (Hace más de 2 años)
Caso # Resultado Tiempo Memoria
#1
Correcto
0.03 s 3 KBi
#2
Correcto
0.031 s 3 KBi
#3
Correcto
0.157 s 3 KBi
#4
Tiempo límite excedido
1.577 s 5 KBi
#5
Tiempo límite excedido
1.569 s 7 KBi
#6
Tiempo límite excedido
1.576 s 18 KBi
#7
Tiempo límite excedido
1.571 s 18 KBi
#8
Tiempo límite excedido
1.587 s 18 KBi
Puntos totales: 38 / 100

Código

from collections import Counter


def counter(arr, x):
    count_dict = Counter(arr)
    return count_dict.get(x, 0)

n = int(input())
arr = [int(num) for num in input().split()]

for _ in range(int(input())):
    l, r, x = input().split()
    print(counter(arr[int(l):int(r)+1], int(x)))