You are viewing a single comment's thread. Return to all comments →
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))
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 →
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))