You are viewing a single comment's thread. Return to all comments →
from collections import Counter x = int(input()) n = list(map(int,input().split())) m = int(input()) sh =[] for i in range(m): sh.append( list( map(int,input().split())) ) dic = Counter(n) total =0 for cust, price in sh: if dic[cust] > 0: # Check if the requested size is available total += price dic[cust] -= 1 # Decrease the count for the size if dic[cust] == 0: # If count becomes zero, remove the size del dic[cust] print(total)
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 →