-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcollectionsCounter.py.0
executable file
·43 lines (36 loc) · 1.19 KB
/
collectionsCounter.py.0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/env python3
"""
Counter - a containter that stores elements as dictionary keys,
and their counts are stored as dictionary values.
INPUT:
X, number of shoes
shoe_size_array, list of all shoe sizes in shop
N, number of customers
next N lines two space separated values:
s p
shoe size price of shoe
OUTPUT:
Amount of money earned
"""
import collections
if __name__ == '__main__':
X = int(input())
size_arr = list(map(float, input().split()))
size_counter = collections.Counter(size_arr)
N = int(input())
money_earned = 0.0
# print('number of shoes: ' + repr(X))
# print('shoe size list available: ' + repr(size_arr))
# print(' collection of same: ' + repr(size_counter))
# print('number of customers: ' + repr(N))
for i in range(N):
s, p = map(float, input().split())
# print('wanted_size: ' + repr(s))
# print('wanted_price: ' + repr(p))
if size_counter.get(s, 0) > 0:
# print('have shoes')
# print('made sale')
money_earned += p
size_counter[s] -= 1
# print('money:' + repr(money_earned))
print("{:.0f}".format(round(money_earned)))