Advertisement
Guest User

Untitled

a guest
Jul 14th, 2020
538
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. submissions = {}
  2. users = {}
  3.  
  4. while True:
  5. line = input()
  6. if line == "no more time":
  7. break
  8. line = line.split(" -> ")
  9. username = str(line[0])
  10. contest = str(line[1])
  11. points = int(line[2])
  12.  
  13. if contest not in submissions:
  14. submissions[contest] = {username: points}
  15. if username not in submissions[contest]:
  16. submissions[contest][username] = points
  17. if username not in users:
  18. users[username] = {contest: points}
  19. else:
  20. users[username][contest] = points
  21. if submissions[contest][username] < points:
  22. submissions[contest][username] = points
  23. if users[username][contest] < points:
  24. users[username][contest] = points
  25.  
  26.  
  27. for k, v in submissions.items():
  28. i = 1
  29. print(f'{k}: {len(v)} participants')
  30. sorted_items = dict(sorted(v.items(), key=lambda x: (-x[1], x[0])))
  31. for k2, v2 in sorted_items.items():
  32. print(f'{i}. {k2} <::> {v2}')
  33. i += 1
  34. print('Individual standings:')
  35. sorted_names = dict(sorted(users.items(), key=lambda x: (-sum(x[1].values()), x[0])))
  36. i = 1
  37. for k,v in sorted_names.items():
  38. print(f'{i}. {k} -> {sum(v.values())}')
  39. i += 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement