Fraudulent Activity Notifications

  • + 5 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 ?