collections.Counter()

  • + 0 comments

    from collections import Counter

    no_of_shoes = int(input()) shoe_size = map(int, input().split()) cus = int(input())

    earnings = 0

    shop = Counter(shoe_size)

    for i in range(cus): cus_shoe_size,price = map(int, input().split()) if shop[cus_shoe_size] > 0: shop[cus_shoe_size] -= 1 earnings += price print(earnings)