collections.Counter()

  • + 0 comments

    How about this one?

    number_shoes = int(input())
    shoe_size = list(map(int,input().split(" ")))
    number_customers = int(input())
    total_sold_value = 0
    
    for _ in range(number_customers):
        customer_purchase = list(map(int,input().split(" ")))
        if customer_purchase[0] in shoe_size:
            total_sold_value += customer_purchase[1]
            shoe_size.remove(customer_purchase[0])
    
    print(total_sold_value)