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

Envío 5238

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

  • Autor: Andres Ariza
  • Fecha: 2021-10-29 02:08:36 UTC (Hace más de 2 años)
Caso # Resultado Tiempo Memoria
#1
Correcto
0.034 s 6 KBi
#2
Correcto
0.022 s 3 KBi
#3
Correcto
0.058 s 3 KBi
#4
Tiempo límite excedido
1.568 s 5 KBi
#5
Tiempo límite excedido
1.525 s 11 KBi
#6
Error en tiempo de ejecución (NZEC)
Exited with error status 137
run: line 1:     3 Killed                  /usr/local/python-3.8.1/bin/python3 script.py
0.571 s 125 KBi
#7
Error en tiempo de ejecución (NZEC)
Exited with error status 137
run: line 1:     3 Killed                  /usr/local/python-3.8.1/bin/python3 script.py
0.537 s 125 KBi
#8
Error en tiempo de ejecución (NZEC)
Exited with error status 137
run: line 1:     3 Killed                  /usr/local/python-3.8.1/bin/python3 script.py
0.403 s 125 KBi
Puntos totales: 38 / 100

Código

from collections import Counter


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

for _ in range(int(input())):
    l, r, x = input().split()
    if (l, r) in cached:
        print(cached.get((l, r)).get(int(x), 0))
    else:
        cached[(l, r)] = Counter(arr[int(l):int(r)+1])
        print(cached.get((l, r)).get(int(x), 0))