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.
X=int(input())
shoe_sizes=list(map(int,input().split()))
N=int(input())
sum=0
for i in range(N):
details=list(map(int,input().split()))
if details[0] in shoe_sizes:
sum=sum+details[1]
shoe_sizes.remove(details[0])
print(sum)
Cookie support is required to access HackerRank
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 →
without using counter
X=int(input()) shoe_sizes=list(map(int,input().split())) N=int(input()) sum=0 for i in range(N): details=list(map(int,input().split())) if details[0] in shoe_sizes: sum=sum+details[1] shoe_sizes.remove(details[0]) print(sum)