collections.Counter()

  • + 0 comments
    1. from collections import Counter
      1. X = int(input()) # number of shoes available
    2. Y = list(map(int,input().split())) # list of size of shoes
    3. counter = Counter(Y)
    4. N = int(input()) # number of customer
    5. sum_list = []
    6. for i in range(1,N+1):
    7. a,b = map(int,input().split())
    8. if(counter[a]!=0):
    9. sum_list.append(b)
    10. counter[a]-=1
    11. print(sum(sum_list))