gokulraaj59's blog

By gokulraaj59, history, 6 weeks ago, In English

code here have made this code in python its giving TLE on Test-16 -> and have also tried with Fast_IO and PyPy too code

please need solutions in python only.

  • Vote: I like it
  • +3
  • Vote: I do not like it

6 weeks ago, # |
Rev. 3   Vote: I like it 0 Vote: I do not like it

I modified your code and it get accepted in python3 without using fastIO template also.
your code is full of operations that take O(n) like count , index and in operator.
so I replace them with bisect functions only to do this operations in O(logn).
so don't use this useless operations and use binary search.

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

My code for same problem.

from bisect import bisect as bis
l = int(input())
arr = sorted(list(map(int,input().split())))
for x_x in range(int(input())):
    n  =  int(input())