We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
total =0
for customer in range (number_of_customers):
size, price = list(map(int, input().split()))
if size in counter_of_sizes.keys():
if counter_of_sizes[size] > 0:
total = total + price
counter_of_sizes[size] = counter_of_sizes[size] -1
print (total)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
collections.Counter()
You are viewing a single comment's thread. Return to all comments →
rom collections import Counter
number_of_shoes = int(input()) size_of_shoes = list(map(int, input().split())) number_of_customers = int(input())
counter_of_sizes= Counter(size_of_shoes)
total =0 for customer in range (number_of_customers): size, price = list(map(int, input().split())) if size in counter_of_sizes.keys(): if counter_of_sizes[size] > 0: total = total + price counter_of_sizes[size] = counter_of_sizes[size] -1 print (total)