-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path0447.py
53 lines (41 loc) · 1.42 KB
/
0447.py
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
44
45
46
47
48
49
50
N = int(input())
Ls = [int(x) for x in input().split()]
T = int(input())
compe_index = { compe:index for index, compe in enumerate('ABCDEFGHIJKLMNOPQRSTUVWXYZ') }
buff = {}
for t in range(T):
name, compe = input().split()
if buff.get(compe) is None:
buff[compe] = []
buff[compe].append( (t, name) )
# ノーマライズ
norm = {}
for compe, data in buff.items():
star_num = Ls[ compe_index[compe] ]
data = [(star_num*50 + star_num * 50 / (0.8 + 0.2*(index+1)), tup[1]) for index, tup in enumerate(sorted(data, key=lambda x:x[0])) ]
norm[compe] = data
#print(norm)
max_char = max( norm.keys() )
max_index = compe_index[ max_char ]
name_series = {}
for compe, data in norm.items():
for score, name in data:
if name_series.get(name) is None:
name_series[name] = []
name_series[name].append( (compe, int(score) ) )
for name in list(name_series.keys()):
obj = dict( name_series[name] )
arr = []
for compe, index in filter(lambda x:x[1] <= N-1, sorted(compe_index.items(), key=lambda x:x[1])):
if obj.get(compe) is None:
arr.append( 0 )
else:
arr.append( obj[compe] )
name_series[name] = arr
tuples = []
for name in list(name_series.keys()):
tuples.append( (name, ' '.join(map(str,name_series[name])), sum(name_series[name])) )
#print(name_series)
#print(tuples)
for index, tuple in enumerate(sorted(tuples, key=lambda x:x[2])):
print(index+1, ' '.join(map(str, list(tuple))))