Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- submissions = {}
- users = {}
- while True:
- line = input()
- if line == "no more time":
- break
- line = line.split(" -> ")
- username = str(line[0])
- contest = str(line[1])
- points = int(line[2])
- if contest not in submissions:
- submissions[contest] = {username: points}
- if username not in submissions[contest]:
- submissions[contest][username] = points
- if username not in users:
- users[username] = {contest: points}
- else:
- users[username][contest] = points
- if submissions[contest][username] < points:
- submissions[contest][username] = points
- if users[username][contest] < points:
- users[username][contest] = points
- for k, v in submissions.items():
- i = 1
- print(f'{k}: {len(v)} participants')
- sorted_items = dict(sorted(v.items(), key=lambda x: (-x[1], x[0])))
- for k2, v2 in sorted_items.items():
- print(f'{i}. {k2} <::> {v2}')
- i += 1
- print('Individual standings:')
- sorted_names = dict(sorted(users.items(), key=lambda x: (-sum(x[1].values()), x[0])))
- i = 1
- for k,v in sorted_names.items():
- print(f'{i}. {k} -> {sum(v.values())}')
- i += 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement