Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Raghu is a shoe shop owner. His shop has X number of shoes. He has a list containing the size of each shoe he has in his shop. There are N number of customers who are willing to pay xi amount of money only if they get the shoe of their desired size. Your task is to compute how much money Raghu earned.
The first line contains X, the number of shoes.
The second line contains the space separated list of all the shoe sizes in the shop.
The third line contains N, the number of customers.
The next N lines contain the space separated values of the shoe size desired by the customer and xi, the price of the shoe.
Print the amount of money earned by Raghu.
10
2 3 4 5 6 8 7 6 5 18
6
6 55
6 45
6 55
4 40
18 60
10 50
200
Customer 1: Purchased size 6 shoe for $55.
Customer 2: Purchased size 6 shoe for $45.
Customer 3: Size 6 no longer available, so no purchase.
Customer 4: Purchased size 4 shoe for $40.
Customer 5: Purchased size 18 shoe for $60.
Customer 6: Size 10 not available, so no purchase.Total money earned = 55+45+40+60 = $200
from collections import Counter
X = int(input())
sizes = Counter(map(int,raw_input().split()))
N = int(input())
earnings = 0
for i in xrange(N):
size,x = map(int,raw_input().split())
if sizes[size]>0:
sizes[size]-=1
earnings += x
print earnings
# Enter your code here. Read input from STDIN. Print output to STDOUT
import collections
numShoes = int(input())
shoes = collections.Counter(map(int, input().split()))
numCust = int(input())
income = 0
for i in range(numCust):
size, price = map(int, input().split())
if shoes[size]:
income += price
shoes[size] -= 1
print(income)
import collections
numShoes = int(raw_input())
shoes = collections.Counter(map(int, raw_input().split()))
numCust = int(raw_input())
money = 0
for i in range(numCust):
size, price = map(int, raw_input().split())
if shoes[size]:
money += price
shoes[size] -= 1
print money
# Enter your code here. Read input from STDIN. Print output to STDOUT
from collections import Counter
num_shoes = int(input())
sizes = [int(i) for i in input().split()] #2 3 4 5 6 8 7 6 5 18
num_cust = int(input())
d = Counter(sizes)
earn = 0
for i in range(num_cust):
#while(input() != null)
req_i = [int(j) for j in input().split()]
req_i_size = req_i[0]
if req_i_size in d.keys():
if d[req_i_size] > 0:
earn += req_i[1]
d[req_i_size] -= 1
print(earn)
In our experience, we suggest you solve this Collections.Counter() Hacker Rank Solution and gain some new skills from Professionals completely free and we assure you will be worth it.
Collections.Counter() problem is available on Hacker Rank for Free, if you are stuck anywhere between a compilation, just visit Queslers to get Collections.Counter() Hacker Rank Solution
I hope this Collections.Counter() Hacker Rank Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Hacker Rank, Leetcode, Codechef, Codeforce Solution.
This Problem is intended for audiences of all experiences who are interested in learning Programming in a business context; there are no prerequisites.
Keep Learning!
More Hacker Rank Problem & Solutions >>
Staircase Hacker Rank Solution
A Very Big Sum Hacker Rank Solution
Diagonal Difference Hacker Rank Solution