Can someone tell me why my solution is getting TLE in Educational Round 107C
its complexity is O(Q*Ai) Q <= 3*(10^5) Ai <= 50
Link to Ques = https://codeforces.net/contest/1511/problem/C
import math
a,b = map(int,input().split())
arr = list(map(int,input().split()))
brr = list(map(int,input().split()))
t = [0]*(max(arr)+1)
for i in range(a):
if(t[arr[i]]==0):
t[arr[i]] = i+1
for i in range(b):
print(t[brr[i]],end = " ")
for j in range(len(t)):
if(t[j]<t[brr[i]]):
t[j]+=1
t[brr[i]] = 1
It works for me: 112911897. Maybe you used CPython instead of PyPy? CPython is quite slow, PyPy is usually much faster.