You are viewing a single comment's thread. Return to all comments →
import collections as c x = int(input()) available_sizes= input() no_of_customers= int(input()) cutomer_and_shoe_price_list= [] for cutomer_shoe_price in range(no_of_customers): cutomer_and_shoe_price = input() cutomer_and_shoe_price_list.append(cutomer_and_shoe_price.split(" ")) available_sizes_list= [i for i in available_sizes.split(" ")] # print(available_sizes_list) available_sizes_list_count= c.Counter(available_sizes_list) # print(available_sizes_list_count) # Counter({'5': 2, '6': 2, '2': 1, '3': 1, '4': 1, '8': 1, '7': 1, '18': 1}) # print(cutomer_and_shoe_price_list) # [['6', '55'], ['6', '45'], ['6', '55'], ['4', '40'], ['18', '60'], ['10', '50']] price_list= [] for keys, values in available_sizes_list_count.items(): for i in cutomer_and_shoe_price_list: if i[0] == keys: values= values - 1 price_list.append(i[1]) if values == 0: # Prevents overselling break # print(keys, values) print(sum(list(map(int, price_list))))
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 →