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.
collections.Counter()
collections.Counter()
Sort by
recency
|
1409 Discussions
|
Please Login in order to post a comment
Why all test cases are not getting passed, can anyone shed some light on my mistake.
Way 1
Way 2
from collections import Counter
X = int(input()) sizes = list(map(int, input().split())) customers = int(input()) orders = list()
for i in range(customers): x, y = map(int, input().split()) orders.append({x: y})
sizes_count = Counter(sizes)
list_prices = list()
for order in orders: k, v = list(order.items())[0] if (k in sizes_count.keys()) & (sizes_count[k] > 0): sizes_count[k] -= 1 list_prices.append(v)
print(sum(list_prices))