Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Incorrecto
|
0.009 s | 3 KBi |
#2 |
Correcto
|
0.021 s | 3 KBi |
#3 |
Incorrecto
|
0.027 s | 3 KBi |
#4 |
Tiempo límite excedido
|
1.596 s | 8 KBi |
#5 |
Tiempo límite excedido
|
1.597 s | 10 KBi |
#6 |
Incorrecto
|
0.727 s | 30 KBi |
#7 |
Incorrecto
|
0.46 s | 29 KBi |
#8 |
Incorrecto
|
0.942 s | 30 KBi |
N = input() arr = input().split(' ') times = int(input()) mem = {} for i, elem in enumerate(arr): if elem not in mem: mem[elem] = [] mem[elem].append(i) for i in range(times): case = input().split(' ') l = int(case[0]) r = int(case[1]) q = case[2] count = 0 if q not in mem: print(0) continue indexes = mem[q] left = 0 right = len(indexes) - 1 # 1, 2, 4, 6 while left <= right: middle = (left + right) // 2 if indexes[middle] >= l: left += 1 else: right -= 1 count += 1 print(count)