collections.Counter()

  • + 0 comments

    Well, I didn't use Counter()... this seemed pretty easy without it

    # Enter your code here. Read input from STDIN. Print output to STDOUT
    # from collections import Counter
    no_of_shoes=int(input())
    size_stocks=list(map(int, input().split(" ")))
    customers_count=int(input())
    request_size_bid=[]
    for i in range(customers_count):
        x,y=input().split(" ")
        request_size_bid.append((int(x),int(y)))
    
    profit=0
    for i in request_size_bid:
        if i[0] in size_stocks:
            profit+=i[1]
            size_stocks.remove(i[0])
    print(profit)