Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- abitur_dict = {}
- title_list = []
- vuz_dict_count = {}
- for _ in range(int(input())):
- title, count = input().split()
- title_list.append(title)
- vuz_dict_count[title] = int(count)
- while True:
- word = input()
- if not word:
- break
- name, *scores, wish = word.split()
- scores = list(map(int, scores))
- abitur_dict[name] = abitur_dict.get(name, {'wish': {}})
- abitur_dict[name]['scores'] = [sum(scores)] + scores
- abitur_dict[name]['wish'][title] = int(wish)
- abitur_list = sorted(
- list(abitur_dict.keys()),
- key=lambda x: abitur_dict[x]['scores'],
- reverse=True
- )
- vuz_dict = {}
- for name in abitur_list:
- wish = sorted(
- list(abitur_dict[name]['wish'].keys()),
- key=lambda x: abitur_dict[name]['wish'][x]
- )
- for title in wish:
- vuz_dict[title] = vuz_dict.get(title, [])
- if len(vuz_dict[title]) < vuz_dict_count[title]:
- vuz_dict[title].append(name)
- break
- else:
- scores = abitur_dict[name]['scores']
- last_scores = abitur_dict[vuz_dict[title][-1]]['scores']
- if scores == last_scores:
- vuz_dict[title].append(name)
- break
- for title in title_list:
- name_list = vuz_dict.get(title, [])
- print(title, len(name_list))
- print(*sorted(name_list), sep='\n')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement