collections.Counter()

Sort by

recency

|

1344 Discussions

|

  • + 0 comments

    I didnt use collections Counter

    from collections import Counter
    num_shoes = int(input())
    shoe_sizes = list(map(int, input().split()))
    num_customers = int(input())
    customer_info = list()
    
    for i in range(num_customers):
        customer_info.append(list(map(int, input().split())))
    
    total = 0
    for i in range(num_customers):
            if customer_info[i][0] in shoe_sizes:
                total = total + int(customer_info[i][1])
                shoe_sizes.remove(customer_info[i][0])
    print(total)
        
    
  • + 0 comments

    from collections import Counter

    No_Shoes = int(input())

    shoe = Counter(list(map(int,input().split())))

    No_Customers = int(input())

    Tsum=0

    for i in range(No_Customers):

    Customer = [int(i) for i in input().split()]
    
    if Customer[0] in shoe.keys() and shoe[Customer[0]] > 0 :
        Tsum+=Customer[1]
        shoe[Customer[0]]-=1
    

    print(Tsum)

  • + 0 comments

    from collections import Counter X=int(input()) S=list(map(int,input().strip().split()[:X])) N=int(input()) lst=[] for i in range(0,N): lst.append(list(map(int,input().strip().split()[:2]))) C=Counter(S) ttl=0 for i in range(0,N): a,b=lst[i] if a in C and C[a]>0: ttl+=b C[a]-=1 print(ttl)

  • + 0 comments
    from collections import Counter
    
    number_of_shoes = int(input())
    shoe_sizes = list(input().split())
    number_of_customers = int(input())
    
    shoe_sizes = Counter(shoe_sizes)
    total = 0
    
    for customers in range(number_of_customers):
        
        size, price = map(int, input().split())
    
        if shoe_sizes[str(size)]:
            shoe_sizes[str(size)] -= 1
            total += price
    
    print(total)
    
  • + 0 comments

    X=int(input())
    S=list(map(int,input().split())) N=int(input()) li=[] for i in range(N): SP=[int(n) for n in input().split()] li.append(SP) summ=0 for i in li: if(i[0] in S): summ += i[1] S.remove(i[0]) print(summ)