collections.Counter()

  • + 0 comments

    Why all test cases are not getting passed, can anyone shed some light on my mistake.

    from collections import Counter
    
    x = int(input())
    s = list(map(int,input().split()))
    n = int(input())
    c = set()
    
    for i in range(0, n):
        j = list(map(int,input().split()))
        c.add(tuple(j))
    
    c = list(c)
    for i in range(0,len(c)):
        c[i] = list(c[i])
        
    d = dict(Counter(s))
    
    su = 0
    
    for i in range(0,len(c)):
        if c[i][0] in d.keys() and d[c[i][0]]>0:
            d[c[i][0]] -= 1
            su = su + c[i][1]     
    
    print(su)