Arksiana

2.Judge

Dec 2nd, 2020
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.35 KB | None | 0 0
  1. contests = {}
  2. data = input()
  3. individual_standings = {}
  4. # data_users = []
  5. while not data == 'no more time':
  6.     username, contest, points = data.split(" -> ")
  7.     points = int(points)
  8.  
  9.     if contest not in contests:
  10.         contests[contest] = {username: points}
  11.         # contests[contest][username] = points
  12.     else:
  13.         if username in contests[contest]:
  14.             contests[contest][username] = points
  15.             if contests[contest][username] <= points:
  16.                 contests[contest][username] = points
  17.         else:
  18.             contests[contest][username] = points
  19.  
  20.     if username not in individual_standings:
  21.         individual_standings[username] = points
  22.     else:
  23.         if individual_standings[username] <= points:
  24.             individual_standings[username] = points
  25.         else:
  26.             individual_standings[username] += points
  27.  
  28.     data = input()
  29.  
  30. for key, value in contests.items():
  31.     print(f"{key}: {len(value)} participants")
  32.     i = 1
  33.     sorted_items = dict(sorted(value.items(), key=lambda x: (-x[1], x[0])))
  34.     for k2, v2 in sorted_items.items():
  35.         print(f'{i}. {k2} <::> {v2}')
  36.         i += 1
  37.  
  38. print('Individual standings:')
  39. i = 1
  40. for key, value in sorted(individual_standings.items(), key=lambda x: (-(x[1]), x[0])):
  41.     print(f'{i}. {key} -> {value}')
  42.     i += 1
  43.  
  44. # TODO 66 / 100 Judge
  45.  
Advertisement
Add Comment
Please, Sign In to add comment