collections.Counter()

Sort by

recency

|

1383 Discussions

|

  • + 0 comments
    # Enter your code here. Read input from STDIN. Print output to STDOUT
    
    from collections import Counter
    
    X = input()
    sizes = input().split(" ")
    N = input()
    
    shoes_summry = Counter(sizes).items()
    shoes_summry = dict(shoes_summry)
    
    earned = 0
    
    
    for i in range(int(N)):
        size_price = input().split(" ")
        shoe_size, price = size_price
        price = int(price)
        
        if shoe_size in shoes_summry:
            if shoes_summry[shoe_size] > 0:
                earned += price
                shoes_summry[shoe_size] -= 1  
              
    
    print(earned) 
    
  • + 0 comments
    from collections import Counter
    N=int(input())
    l=list(map(int,input().split()))
    n=int(input())
    counter=Counter(l)
    s=0
    for i in range(n):
        size,price=map(int,input().split())
        if counter[size]>0:
            s+=price
            counter[size]-=1
    print(s)
            
    				
    
  • + 0 comments
    from collections import Counter
    
    X = int(input(""))
    X_list = list(map(int, input("").split()))
    N = int(input(""))
    
    shoe_size = Counter(X_list)
    sum = 0
    for i in range(N):
        size, amount = tuple(map(int, input("").split()))
        if size in shoe_size.keys() and shoe_size[size] != 0:
            shoe_size[size] -= 1
            sum += amount
            
    print(sum)
    
  • + 0 comments
    from collections import Counter
    X = int(input())
    size = list(map(int, input().split(' ')))
    csize = Counter(size)
    N = int(input())
    sum = 0
    for i in range(N):
        s,price = list(map(int, input().split(' ')))
        if s in csize.keys():
            if csize[s]>0:
                sum += price
                csize[s] -= 1
    

    print(sum)

  • + 0 comments

    You can think of it like playing touchcricket with the available shoes, if the right size is "in play," the customer can score a purchase, and you earn money!