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
|
1286 Discussions
|
Please Login in order to post a comment
A simple solution
Using a function to organize the input:
# Enter your code here. Read input from STDIN. Print output to STDOUT from collections import Counter
def get_input(convert_func=int): return list(map(convert_func, input().split()))
input()
shoe_inventory = Counter(get_input()) num_cust = int(input())
income = 0 for _ in range(num_cust): size, price = get_input() if shoe_inventory[size]: income += price shoe_inventory[size] -= 1
print(income)
from collections import *
num_of_shoes=int(input()) shoe_sizes=list(map(int,input().split())) cust=int(input())
total=0 for i in range(cust): a,b=input().split() if int(a) in shoe_sizes: total+=int(b) shoe_sizes.remove(int(a))
print(total)
Python 3
-