collections.Counter()

  • + 0 comments

    Here's my solution to this problem:-

    from collections import Counter shoes=int(input()) shoe_size=list(map(int,input().split())) counter=Counter(shoe_size) customers=int(input()) lst=[] for i in range(1,customers+1): customer_info,price=map(int,input().split()) if counter[customer_info]>0: counter[customer_info]-=1 lst.append(price) else: pass print(sum(lst))