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
|
1375 Discussions
|
Please Login in order to post a comment
import collections
X = int(input()) c = collections.Counter(map(int, input().split())) N = int(input()) total = 0
for i in range(N): s, p = map(int, input().split()) if c[s]: c[s] -= 1 # Reduce stock count total += p
print(total)
I try using this way
Completed using the methods in the documentation: