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())
S=list(map(int,input().split()))
N=int(input())
li=[]
for i in range(N):
SP=[int(n) for n in input().split()]
li.append(SP)
summ=0
for i in li:
if(i[0] in S):
summ += i[1]
S.remove(i[0])
print(summ)
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 →
X=int(input())
S=list(map(int,input().split())) N=int(input()) li=[] for i in range(N): SP=[int(n) for n in input().split()] li.append(SP) summ=0 for i in li: if(i[0] in S): summ += i[1] S.remove(i[0]) print(summ)