ritik652000's blog

By ritik652000, history, 5 weeks ago, In English

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.com/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):
        t[arr[i]] = i+1
for i in range(b):
    print(t[brr[i]],end = " ")
    for j in range(len(t)):
    t[brr[i]] = 1
  • Vote: I like it
  • -9
  • Vote: I do not like it

5 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

It works for me: 112911897. Maybe you used CPython instead of PyPy? CPython is quite slow, PyPy is usually much faster.