collections.Counter()

Sort by

recency

|

1351 Discussions

|

  • + 0 comments
    from collections import Counter
    
    earned = 0
    
    X = int(input())
    available = list(map(int, input().split()))
    N = int(input())
    
    for customers in range(N):
        shoe_size, price = map(int, input().split())
    
    if shoe_size in available:
        if Counter(available).values() != 0:
            available.remove(shoe_size)
            earned += price
        else:
            continue
    

    print(earned)

  • + 0 comments
    from collections import Counter
    
    X = input()
    number_of_shoes = map(int, input().split())
    
    inventory = Counter(number_of_shoes)
    earnings = 0
    
    for _ in range(int(input())):
        size, price = map(int, input().split())
        if inventory[size] > 0:
            inventory[size] -= 1
            earnings += price
    print(earnings)
    
  • + 0 comments

    from collections import Counter

    X, shoe_sizes = input(), map(int, input().split())

    inventory = Counter(shoe_sizes) earning = 0

    for _ in range(int(input())): size, price = map(int, input().split()) if inventory[size]: inventory[size] -= 1 earning += price

    print(earning)

  • + 0 comments
    from collections import Counter
    
    if __name__ == "__main__":
        X = map(int, input())
        sizes = list(map(int, input().split()))
        N = int(input())
        demand = [list(map(int, input().split())) for i in range(N)]
        
        income = 0
        sizes = Counter(sizes)
        for size,price in demand:
            if sizes[size] != 0:
                income += price
                sizes[size] -= 1
        print(income)
    
  • + 0 comments
    from collections import Counter
    X = input() # number of shoes
    shoeSizes = Counter(list(map(int, input().split())))
    N = int(input())
    total = 0
    for _ in range(N):
        customer = list(map(int, input().split()))
        try:
            shoseSize = shoeSizes[customer[0]]
            if shoeSizes[customer[0]] > 0:
                total += customer[1]
                shoeSizes[customer[0]] -= 1
        except:
            pass
    
    print(total)