collections.Counter()

  • + 0 comments

    I try using this way

    import sys
    
    linhas = sys.stdin.read().splitlines()
    amount = 0
    X = int(linhas[0])
    shoes_sizes = linhas[1].split()
    N = linhas[2]
    for linha in linhas[3:]:
        Customer = linha.split()
        shoe_size = Customer[0]
        price = Customer[1]
        if shoe_size in shoes_sizes:
            shoes_sizes.remove(shoe_size)
            amount += int(price)
            X -= 1   
    print(amount)