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