我得到一个错误的答案 problem:Hackerrank

I am getting a wrong answer for this problem:Hackerrank

Raghu 是一家鞋店老板。他的商店有 X 件鞋子。 他有一张清单,上面列有他店里每只鞋的尺码。 有n位顾客愿意支付y

只有在他们得到他们想要的尺码的鞋子时才会有金额。

你的任务是计算多少钱 赚到了。

我知道这个问题对你们来说似乎毫无用处developers.But我和python一样是编程初学者。所以,请帮助我 this.I 已经尝试了很多次,但我能得到的唯一答案是 0.Here 我的解决方案是:

from collections import Counter
numshoes=int(input())
shoes=Counter(map(int,input().split()))
numcust=int(input())
income=0
for i in range(numcust):
    size,price=input().split()
    if(shoes[size]>0):
        income+=price
        shoes[size]-=1
    else:
        pass
print(income)

输入:

10

2 3 4 5 6 8 7 6 5 18

6

6 55

6 45

6 55

4 40

18 60

10 50

你的输出(标准输出)

0

预期输出

200

这是我得到的输出。

sizeprice 是字符串。在添加到收入之前将它们转换为整数,就像您对 shoes.

所做的那样

(作为忠告,我建议自己解决 Hackerrank 问题,因为它的目的是挑战。)