You are viewing a single comment's thread. Return to all comments →
I was able to use the statistics module and get the basic test cases passing. However when I submit, only #1 test case pass and rest all times out.
import statistics n,d = input().split(" ") d= int(d) n = int(n) a = [int(i) for i in input().split(" ")] count = 0 for i in a[d:]: if i >= 2*statistics.median(a[:d]): count += 1 print(count)
I think I need to implement a "running median" function using heaps. Any better idea folks ?
Seems like cookies are disabled on this browser, please enable them to open this website
Fraudulent Activity Notifications
You are viewing a single comment's thread. Return to all comments →
I was able to use the statistics module and get the basic test cases passing. However when I submit, only #1 test case pass and rest all times out.
I think I need to implement a "running median" function using heaps. Any better idea folks ?